r/dailyprogrammer_ideas • • Mar 17 '19

Idea: How do I code the following project?

0 Upvotes

Hi fellow Python learners,

I am a Business Major(25), so I don't have a strong math background, though finance skill is pretty fine. So, I want to dive into tech and trying to learn code and later on statistics and probability. (though I am following a class called: software design with Python and C for a semester ^_^, very happy about that)

Python level: beginner

IDEA

So, I realised the best way is to learn coding by doing projects and solving problems. I would like to build a simple budget tool that can tell me what my average daily expenses have been on the last 30 days.

What I would like to have is the following:

Shortly explained

Input:

- expenses by the day, such as: groceries, food, transport, impulsive buys etc. (variable expenses basically) by category, description and amount

blackbox:

- it needs to have a daily expense amount by default (i.e. $15 p/day $450 p/month), so it can tell me later on by what amount/% per day/month, I surpassed that amount.

- the code script itself obviously

Output:

- my total spending over the last month and difference with the default in $/%.

(i.e. $540(total expenses last month)- $450(default) = $ 90 / + 20%

- continuous line of my average daily expenses and difference with the default in $/%.(i.e. $18(total expense of the day)-$15(default) = $3 / + 20%) on 17th march

Sidenote: month = 365 / 12 of course

Extra: it would be even cooler if I could first enter my variable income for the month. Then take off fixed costs such as: rent, insurances, subscriptions etc. and determine what % I would like use as disposable income. Perhaps, maybe even do something with forecasting.

Goal: to see what my daily expenses are in the last 30 days, example: if I would do a impulsive buy for lets say $50, then how this effect my average spending in the last 30 days and to show me by how much $/% I surpassed my daily/monthly disposable income.

Question: where do I start and how can code this (I am talking about general advice/explanation such as which concepts to use, which modules, which functions etc.)

I have a feeling that I underestimate the scale of this project, since it would need to store the data somehow and that I would need to fill it in everyday(perhaps if I forget it for a day or few, it can go ahead and auto-fill the default amount). Though, I like challenges. So, I don't mind investing time into it.

Of course any additional ideas or feedbacks to the project is more than welcome. This whole idea might not even make sense, in that case don't hesitate to ask if things are unclear.

Thanks


r/dailyprogrammer_ideas • • Nov 20 '12

[Intermediate] Formatter for daily_programmer subreddit (or reddit in general)

0 Upvotes

Whenever I want to change something and reply, the formatting gets messed up.

A better way would be to script this all, declaring "input" or "functions", having a little test that prints, and capturing the output. Add tabs to all code, place code in the clipboard (or into a file, for an easier challenge), and paste.

I've seen a lot of 'nestling' in daily_programmer, where something I did before comes in handy again, this program would be pretty handy and be useful later.

Edit: I'll add an example.

Say I have the function: (The formatting is messed up a little)

def answer(string): return string[0:5]

for t in ["ojfiaojawoeijf", "iaowejfo", "awiefjoawef"]: print answer(t)

Calling the formatter function would return (either in clipboard or a file):

Input:

def answer(string):
    return string[0:5]

for t in ["ojfiaojawoeijf", "iaowejfo", "awiefjoawef"]:
    print t, answer(t)

Output:

ojfiaojawoeijf ojfiao 
iaowejfo iaowej
awiefjoawef awiefj

r/dailyprogrammer_ideas • • Jun 04 '12

Convert else-ifs to switches

0 Upvotes

Sometimes programmers will write a block of code with else-ifs that would be easier to read with a switch statement. Write a program to convert one to the other. For instance, such a program would turn this code:

if (a == 1) {
    do something;
    do something else;
} else if (a == 2) {
    do this other thing;
    and another thing;
} else if (a == 3) {
    do a third thing;
    and something else;
} else {
    do a last thing;
}

into this:

switch(a) {
	case 1:
        do something;
	    do something else;
	    break;
    case 2:
        do this other thing;
        and another thing;
	    break;
    case 3:
        do a third thing;
        and something else;
	    break;
    default:
        do a last thing;
}

For a bonus, you could make it so it outputs simple else-ifs on a single line. For example:

if (a == 1) {
    do something;
} else if (a == 2) {
    do this other thing;
} else if (a == 3) {
    do a third thing;
} else {
    do a last thing;
}

would turn into

switch(a) {
    case 1: do something; break;
    case 2: do this other thing; break;
    case 3: do a third thing; break;
    default: do a last thing;
}

r/dailyprogrammer_ideas • • Oct 23 '18

NO DON"T SAY EASY

0 Upvotes

hello guys i am new here and a beginner and i really want to learn to break problems down into smaller problems and someone recommend me dailyprogrammer and when i looked at the easy list i could not understand a thing i know i am a beginner but still it says easy and i don't understand it and when i look at the reply's allot and they also have problems with the challenge and i don't like that because it makes the beginner (myself) think that i need to study more and when the problem in general is the challenge please fix this with my saying [beginner] because i just don't like problem and it needs to be fixed ASAP


r/dailyprogrammer_ideas • • Oct 23 '18

your projects vs dailyprogrammer

0 Upvotes

hello i am learning to break problems down into smaller problems and thinking is it best to come up with on by yourself or follow dailyprogrammer ? which do you think is easy and better for a beginner ?


r/dailyprogrammer_ideas • • Aug 18 '14

Submitted! [Hard] Classification Algorithms

1 Upvotes

I noticed you dont have a lot of machine learning algorithms going on so here is an idea...


Part 1:

Create a sparse matrix with a large number of dimension like 1000 rows and 120,000 columns with different values in it.

Create a list of labels for the corresponding sparse matrix with the same number of rows and have a fixed number for the type of labels such as 20 or 25.

Create a testing set which is a smaller sparse matrix with corresponding labels


Part 2:

Input:

  1. Training input which is a Random Sparse matrix of large number of rows and columns say 1000 x 120000 matrix from the previous part.

  2. Classification label for each row in the training input from the previous part.

Problem:

  • Perform dimensionality reduction using algorithms like Principal Component Analysis


Part 3:

Input: The reduced matrix from the part 2

Problem:

  • Perform your favourite supervised learning classifiers like naive bayes and train the training set by doing say 5 fold validation etc after doing dimensionality reduction.


Output:

Use the testing set in the created classifier to test the accuracy.


Note: I remember doing this in my first semester but we had data given and i am not sure if its ok to post it here and i neither have the labels of the testing set which was given to us since that is with the professor .. thats why i am asking here to make your matrix as part 1.
I would suggest solving using mathematics oriented language like matlab since the other languages could get messy

Also this problem is difficult and could be considered for a weekly challenge too!


Edit: Also this might be a difficult problem and it could be considered for a weekly challenge even.

Some good materials for doing this are given below:


Also do note that this is a large challenge and the method for doing this is quite clear

  1. have a sparse matrix

  2. have a label for each row

  3. reduce the matrix

  4. apply classification algorithm and train it

  5. test using the testing matrix

  6. check accuracy

But the challenge lies in able to following these steps ;)


MODS DO READ THIS :D

Since this is a quite large challenge, You could make the Part 2 and Part 3 as separate weekly challenges too! It might give people more time and make it easier


r/dailyprogrammer_ideas • • Apr 20 '17

[Intermediate] PHP fibonacci in as few chars as possible

1 Upvotes

Description

i challenge you to write a php script that writes the first 50 numbers of the fibonacci sequence to the screen, each on a new line and in as few chars as possible

Input description

it expects nothing as an input....

Output description

the first 50 numbers of the fibonacci sequence each on a new line

Notes/Hints

https://en.wikipedia.org/wiki/Fibonacci_number


r/dailyprogrammer_ideas • • Mar 28 '14

Difficult [Intermediate] Evacuation

1 Upvotes

(Hard): Evacuation

Previous | Index

The walls, although they have kept humanity safe, are starting to crumble. In a desperate gambit for survival, the government has built a massive high-tech spaceship for all of the citizens to evacuate in and hopefully find a new planet to colonise. You have been assigned to ensure that the evacuation of the people to the spaceship occurs safely. However, the spaceship has been built some distance away from the people, and there are obstacles impeding the path. You must navigate the people successfully through the obstacles to the spaceship as quickly as possible.

The area between the people and the spaceship can be described as a nxn 2d matrix. Some squares contain obstacles, except for the extreme left-most and right-most columns, which are always obstacle free. Your people start on the left-most column, one group of people per square. The entrance to the spaceship is located on the right-most column. Groups of people will stay together no matter what, so they can be thought of as a single 'unit' of people. Each day, a unit may move one square in the four cardinal directions or stay in place. A unit cannot move into a square that contains an obstacle, nor can two units occupy the same position. Units move simutaneously each day, so a unit may move into a position occupied by a different unit provided that the other unit moves elsewhere in the same day.

Your task is to determine the fewest number of days required to move all of your units of people from the left-most column to the right-most column.

Formal Inputs And Outputs

Input Description

Input will be from STDIN, read from a text file input.txt located in the working directory of the operating system, or supplied as a command line argument, whichever is most convienient for the language you choose to write in.

The first line of input consists of a single integer n, indicating the size of the area. Following this will be n lines consisting of n characters each. It can be assumed that these lines will only be made up of the characters x and .. If the character is an x, it indicates an obstacle in that position, whereas if it is a ., it indicates no obstacle. There will never be an obstacle in the left-most and right-most columns, and there will always be at least one obstacle-free path from the left-most side to the right-most side.

Input Limits

  • n <= 20

Output Description

Output consists of a single integer with the minimum number of days required to evacuate all the people (move all units from left-most column to right-most column).

Sample Inputs and Outputs

Sample Input 1

5
.....
.x...
...x.
..x..
.....

Sample Output 1

6

Sample Input 2

7
.x.....
.x.....
.x.....
.x.....
.x.....
.xxx...
.......

Sample Output 2

12

Note: This may be more difficult than I originally expected. Consider the following input:

5
.x.x.
.xxx.
.....
.xxx.
.x.x.

My original solution comes up with 8 for the output, which is incorrect. Need to think about this puzzle more.


r/dailyprogrammer_ideas • • Aug 12 '12

[easy] Sleepsort

1 Upvotes

Sleepsort is a sort that sleeps for the length of the number it's trying to sort. It was originally made in Bash by someone on 4chan.


r/dailyprogrammer_ideas • • Feb 29 '16

Submitted! Guess my hat color

1 Upvotes

Description

You are the game master of the game "Guess my hat color".

The game goes as following:

  • You put a group of n people in one row, each facing the same direction

  • You assign a collored hat to each person of the group

  • Now you let each person guess the color of their own hat, starting with the last person in the row.

There are only 2 colors of hats and each person can only see the color of hats in front of them. The group wins from the gamemaster if they can win by making only 1 mistake.

The challenge today is to write the logic to make the guess.

The person guessing can only see the persons in front of them (and their hats) and can hear the guesses from the persons behind them. They can NEVER look behind them or look at their own hat.

Formal Inputs & Outputs

Input description

You get the list of hat colors starting with the person in the back and going to the front

Input 1 - 10 hats

Black
White
Black
Black
White
White
Black
White
White
White

Input 2 - 11 hats

Black
Black
White
White
Black
Black
White
Black
White
White
White

Output description

You have to show the guesses of the persons and wether they passed the challenge (they should if your logic is correct).

Notes/Hints

Obviously if you return at random Black or White this won't work. The person units will have to work togheter to get a result with maximum 1 mistake.

Bonus

Here you have a large set (10000 hats). Make sure your program can handle this.

Finally

Have a good challenge idea?

Consider submitting it to /r/dailyprogrammer_ideas


r/dailyprogrammer_ideas • • Dec 10 '18

[Easy To Hard] Introducing /r/OpenSourceVSTi and A Contest For Making VST's Using AirWindows FOSS Code -- Developers & All Ideas Wanted!

1 Upvotes

r/dailyprogrammer_ideas • • Nov 21 '15

Submitted! [Intermediate] Largest Palindrome

1 Upvotes

Description: Write a program that, given an integer input n, prints the largest integer that is a palindrome and has two factors both of string length n.

Input Description: An integer

Output Description: The largest integer palindrome who has factors each with string length of the input.

Sample Input:

1

2

Sample Output:

9

9009

(9 has factors 3 and 3. 9009 has factors 99 and 91)

Challenge inputs/outputs:

3 => 906609

4 => 99000099

5 => 9966006699

6 => ?

Extra Credit:

  1. Also print the factors of the solution that fulfil the requirement.

  2. If you encounter a prime number that is a palindrome before encountering what would other wise be the solution, print that instead and note that it is prime in output. Only consider primes within the range of possible normal solutions

My solution in ruby:

https://github.com/Andrewsh86/largest_palindrome

Potential Gotchas:

The search range will grow very, very quickly as inputs increase. My solution handles the input 5 in about 15 seconds and I've determined that the culprit is in determining whether or not a number has correct factors. I'm interested in seeing how people optimize for solving for 5 and 6.


r/dailyprogrammer_ideas • • Nov 30 '14

[easy?] tilt a webpage backwards to reveal just how high it is

1 Upvotes

I really don't know enough about programming to be able to follow the sidebar. It sorta like this: http://i.imgur.com/wMkpFWz.jpg, though.


r/dailyprogrammer_ideas • • Sep 12 '12

[easy] Top 10 highest scores.

2 Upvotes

Write a function that takes an integer (score) and a string (player name) and stores them in descending order. For the list to be relevant it should only contain a finite number of scores, eg. the top 10. So at the end of every game the program needs to decide whether the new score needs to be included to the list - and the current one dropped - or not. The list should be stored in a text file so it can easily be retrieved and updated after every game. Also, if 2 equal scores are entered the one entered first will have precedence and be considered the highest.


r/dailyprogrammer_ideas • • Oct 17 '18

[Intermediate] GDPR madness

2 Upvotes

Description:

A good old outer-join situation: You have 2 lists, and want to compare them for differences. Some records might be missing in either list, or there might be differences in the record contents.

But they are located in different sources, and you can't transfer the data itself due to a recent policy change, also known as GDPR.

Can you device a way to find the differences within these constraints?

Input

You are given desired accuracy (~=0, measured as the average number of false postives (missed differences) compared to the total number or records); and 2 named files, each starting with the amount of lines they contain.

Output

Return 2 lists containing the line numbers (zero indexed) for lines which are not present in both files, including an indication for each line source.

Example

Input

0.00390625

Foo
6
In a village of La Mancha, 
the name of which I have no desire to call to mind, 
there lived not long since one of those gentlemen that keep a lance in the lance-rack, 
an old buckler, 
a lean hack, 
and a greyhound for coursing. 

Bar
5
there lived not long since one of those gentlemen that keep a lance in the lance-rack,    
a lean hat, 
and a greyhound for coursing. 
the name of which I have desire to call to mind, 
In a village of La Mancha, 

Output

Foo 1 3 4
Bar 2 3

Bonus

It appears the datasets are massive (TBs), and available network bandwith is a significant bottleneck. Can you optimize your solution so the amount of data transfered is somewhat minimized?

Finally

Have a good challenge idea?

Consider submitting it to /r/dailyprogrammer_ideas


r/dailyprogrammer_ideas • • Jun 27 '14

Submitted! [Intermediate] Generate a simple minecraft world

2 Upvotes

A minecraft world is a 3d array where each cell is a material. In this simple world, the materials are rock, tree, air, water.

For extensibility, you should probably maintain a 3d array that holds a value for every cell, but this challenge does not require it. You will generate a world procedurally, and display the 2d map that is the altitude of the highest rock on the grid (overhead view).

Generating rules: Air is above rock.
There should be no altitude gap higher than 1 for the highest rock layer relative to its neighbours.
Trees are randomly placed at the surface. (after water) Water is generated by placing one "drop" randomly, and letting it flow to a valley. Once it reaches the lowest point, it spreads to all of the points at the same altitude (water is cloned there). If less than 10% of area is covered by water, a new drop is placed randomly, and allowed to flow. If it touches existing water, then an extra layer of water is spread at the altitude 1 above the previous layer.
If still less than 10% total water, reapeat.

INPUTS: 3 numbers representing width, length, height

OUTPUT: number that is z layer of lowest altitude top rock

2d array of symbols where: a-z - bear rock. a is altitude 0 above lowest z number. b = 1. A-Z - tree. A is altitude 0. Z altitude 26. 1-9 - water. The number indicates the depth at that square until rock is reached.

Different, more advanced displays, are encouraged.


r/dailyprogrammer_ideas • • Jul 24 '12

[easy] possibly [intermediate] make a program that will "read the users mind"

2 Upvotes

the idea is that the program prompts the user to think of a person or thing real or fictional to think of. The program then asks a series of questions until it either reaches an asnwer.

now this seems stupidly easy all you need is a series of if statements filtering through a bank of data.

BUT HERE IS THE KICKER. try to set it up so that if the program guesses wrong you can add your person/thing to the data bank and a question that differentiates between your answer and the one the program gave. if you do this right you only have to hard code the first few and then can build the program by playing the game

its a neat sort of fake AI trick that you see on the internet and i helped my friend code on of these for a CS I final project


r/dailyprogrammer_ideas • • Dec 12 '13

[Hard] Design an RSA encryptor/decryptor (modular arithmetic)

3 Upvotes

Background:

You are a spy, working deep under enemy lines. With phone lines unsecure, you need to find another way to communicate with HQ. You decide to program an encryption program to send and recieve messages.

Objective:

Implement an RSA encryption/Decryption algorithm. There must be a menu, where the user can decide if he/she wants to encrypt a message or decrypt. Encryption writes the key into a file, decryption reads from a file (who wants to memorize the keys?? Not us lazy programmers thats for sure lol).

Output Requirements:

a sample to show what RSA returns:

please enter the message to be encrypted Joe

The encrypted message looks like: [93588767017231253202615904064528931518875777912113750174453194762537638405941466725956950917243693901241054583517218209165598339927611333588972270279969318551602643591610900036039299387870626977801588665554149611981102956164023785957912898769796043369407641643995280508670026694399103796424200539152151661728482010506522491008442701877854718497649913167715184487748675432609607375737493745765122078550889260218492514882179558557925671758939510663495598477714098556370575717685145249585605441604245965364249987843554878577803269544537626513887251108346061310390969714407257883829405586893236486612444821899479694093788347451216951110016027731087494966254215636919763341578813441533128754814561168517592348676113992746697928011674374317746253260295003130452422797974985269698741472283833587594112533067913626813123514670261295807389191098835250496394464353404697914260435160801249623657074958943636644044398433397758157921525848519246785870115518888592553541831852241241676199244591440617856995172045347984779449901394284539426841432930004001150767282505847347170318517320004283709141882893107514953934714696764367517205132022881203762108332392153296070865185432729159825795715330548781927569548206279477071997843809823783019396648160, 177701333697642581158223123531511443267737710751940317555476385078479241884114027999413980609513742441301055302423952691690302683945406727064289556515292485702702953720410906741957483892335341912355577467388487860188490658674801211685045946939238026349324488766081084536187457061461632552938301139215114671179755644186322471537000512580185308572708599708778986718421180142247229728096099401730860420177791428251288720958980712898034001277341390020452333901898869961996317536781961633255980079720542528644532827599783141264771513604926655200793310994908541087490991838370626876936037380968307285537285278744355305269193175500995019328773570348716998760350360632879340201870244519920019702297195895320748791723604194233000144440883964934095706521353207720916103785390685002508752009519844638542799678138198753759147464246631284383668084334938305313997265802519865277068553330035631356259747489633742705464195339644607095329954987299924931473206559431802471606991019667322499780896846055607556233448975899431045973252199232156415666079973467454427097782210047955949649225631714724178995817550722282129945495954743042397260979720597168351551050482345786334037799396850699532188057850840724001627611206397078496243838272240162345272698729, 563132823307401407939088310363473472909449264296586256465156845434479636656365515143381465594285997862596037834696833058705050887007588677714027356437796905481080436334024016133549347762234839147249810823374529390836629837394243357604086412098695385597623732322177807486180862973724959335284212397122353773069575116641786836450159002273500243556315523232403487328277362851558629012271236897463466918065080131545237133006819669716956923766620805470624240303338997653145883250501886927993279625651968678468275546836755536875407945204426092089863032306056584422827767678289048056386998698373350030252024731945425015079263468074873866804256970087320577196350736805399740829953086307828669906920406924400605407862845086078599735692700841031236978146844204741738446062931175810071776916699445324116789007570601887551651214212972663938625092742802689266854032721236860518511251631854789534802856661860237924042562321136709875743418069028036880118000584652464924703521303050450822847485132035031966004688466697970236823838700453176834910845139757439109474702300129350219797529919501381676088551847225725328441217087436378600754787279570231777040112918545230164546279031856103932760197996020537446468479789201566279226425375172018971156751324]

The recieved message looks like this:

Joe

Time diff. = 1619.0 milliseconds


You will need a menu with 3 options. The first it to write the Private keys to .txt file. The second is to encrypt a message and write the encrypted message to a .txt file. And the 3rd is to decrypt the message in a.txt file and display the message.


r/dailyprogrammer_ideas • • Apr 18 '12

My buddy just showed me this site, it's used by Facebook to test programmers capabilities and has plenty of tests. It seems to be updated fairly often.

Thumbnail interviewstreet.com
3 Upvotes

r/dailyprogrammer_ideas • • Mar 02 '19

[easy] digital 'cut-up technique' text editor

3 Upvotes

Hey coder ppl,

I have an idea for a simple app that I'd like to exist (but I haven't coded anything myself since Flash Actionscript 1.0).

If someone's looking for a weekend project, here's the concept:

An app for writing with a digital cut-up technique. Can be used for writing song lyrics, poems, or just arranging thoughts / brainstorming.

You type in the text box on the bottom left, hit enter, and a block appears on screen containing your text snippet.

You can move the pieces around, take a screenshot, or drag unwanted snippets to the recycle bin.

The app is called something hip like ENTR and it's for desktop use but could be cool on phones too.

Here's a concept pic

https://imgur.com/a/EjV34ft


r/dailyprogrammer_ideas • • Jun 25 '14

21 Puzzles That Programmers Will Like (X-Post /r/programming)

3 Upvotes

Any one of these could easily be an /r/dailyprogrammer challenge. I'm on my phone, so I can't reformat using the standard style.


r/dailyprogrammer_ideas • • Nov 10 '16

[hard] Sorting a list, in a different language.

3 Upvotes

Description

We all know how to sort a list. Whether we use quicksort, heap sort, bubble sort or some other algorithm, most of us can put together a sorting algorithm when needed.

Today, however, you're at a client's site, and the programming languages you're familiar with aren't available.

Choose a programming language you've never used before, and implement a sorting algorithm to sort a list of integers. The more esoteric the language, the more geek points you earn.

No cheating! You must actually implement a sorting algorithm from scratch and not use the language's own sorting methods.

Formal Inputs & Outputs

You're given this list of 100 integers:

98 63 1 70 0 10 41 97 95 62 55 10 100 66 68 41 11 56 88 60 79 90 64 80 7 62 37 95 50 20 61 29 74 38 80 66 0 30 96 68 39 30 83 27 86 38 77 58 84 47 5 86 96 16 28 50 56 0 46 13 51 26 26 17 18 24 32 85 96 96 55 33 84 56 56 46 6 52 29 49 67 64 18 47 69 30 41 68 22 62 23 69 79 88 97 65 80 37 16 64

Output description

Print out the list after it has been sorted:

0 0 0 1 5 6 7 10 10 11 13 16 16 17 18 18 20 22 23 24 26 26 27 28 29 29 30 30 30 32 33 37 37 38 38 39 41 41 41 46 46 47 47 49 50 50 51 52 55 55 56 56 56 56 58 60 61 62 62 62 63 64 64 64 65 66 66 67 68 68 68 69 69 70 74 77 79 79 80 80 80 83 84 84 85 86 86 88 88 90 95 95 96 96 96 96 97 97 98 100

Notes/Hints

Wikipedia has a respectable list of sorting algorithms to choose from.

Bonus

Many languages allow you to write a generic sorting algorithm, where the comparison operator used to compare each item in the list can be defined outside the algorithm. Usually this is done using an anonymous function, pointer to a function, closure, block or lambda expression.

Make your algorithm able to accept a comparison function as an argument. Implement a comparison function where numbers are sorted by the number of divisors they have. This function takes two numbers as input. It returns true if the second number has more or the same number of divisors than the first number, and false otherwise. Use this function to sort the numbers.

Have a good challenge idea?

Consider submitting it to /r/dailyprogrammer_ideas


r/dailyprogrammer_ideas • • Nov 09 '12

[Unknown] Write a program that prints "Hello World!" in the complex and convoluted way you can think up. Line limit of ~20.

3 Upvotes

To clarify, the program is the convoluted part, not "Hello World!". In about 25 lines, write a code that at first glance doesn't look like it would print "Hello world", but does end up producing the text through a interesting or convoluted procedure.

The only other conditions are it be around 25 lines (slightly more if you need it) and it is atleast partially your code.


r/dailyprogrammer_ideas • • Nov 05 '12

[easy] Caesar Shift

0 Upvotes

Edit: Apparently this is very similar to todays easy. Sorry, I haven't looked through the easy challenges ina bit. My bad.

Not sure if this one has already been done or not, but I find myself needing this functionality in programming frequently. There might already exist libraries for this functionality, but I felt this might still be a quick and fun exercise.

Implement a program that will take a string and an integer, and give back the Caeser Shifted string. For example, a popular Caeser shift is the ROT13 encryption, typically used for bypassing language filters and the like.

If we had the string "Hello Dailyprogrammer!" It's ROT13 Caeser Shift would be "URYYB QNVYLCEBTENZZRE!"

Difficult Bonus: Write an auto decrypter, that will test all 26 shifts and re-produce the clear text given an encrypted string.

edit: Link to Caeser shift for those who don't know what it is.


r/dailyprogrammer_ideas • • Jul 10 '13

[Hard] Building a digital Pseudo-Hydrometer(ratio alcoholometer)

0 Upvotes

First of all, a classical hydrometer works by measuring the density of a liquid. Normally using physical displacement. This idea sprang forth from a meeting with a on&off again friend on the 4th of July. Here's the scenario: I call up buddy to buy a quart of true redneck moonshine. I ask, in passing of the transaction, what the proof might be. Said guy responds by laughing and asking if I, or anyone I know has a hydrometer* (*see notes loose useage of hydrometer). I didn't, but here is where the challenge starts.

As mentioned before a typical hydrometer reads by displacement referenced with the boyancy. What I am suggesting is different. Take distilled water, for example. We know what the capacitance and resistivity of it works out to. But take water in solution with alcohol. Can you find out the capacitance or resistivity of alcohol in solution with water? (calculations in the end should be approximations due to minerals and TDS's in a bottle of booze you'd buy, this is due to watering-down post distillation. Which is a travesty honestly). Good news is my subject was single distilled resulting in only pure water and alcohol (possibly a tad of methonol but who knows how those rednecks do quality control).

Done rambling now.... Back to capacitance and resistivity.. The direction you take is up to you. Start by finding the resistivity or capacitance of distilled water. Then find the resistivity or capacitance of ethyl alcohol (hint:alcohol isn't very friendly when it comes to passing current). If you can't find any docs on ethyl electrical properties you might try either grabbing some booze, (take a swig at this stage, just to steel you to carry on), and doing some tests. Hint #1: try passing current through some clear booze you know the proof of. Pass it through to a capacitor and read how long it takes to top out. With multiple tests like this, on various liquors. You should be able to build a scale of the properties of sweet sweet booze. Thats just one way I would try, who knows maybe you could determine by tests the pull-down of the hooch you've got. I would think this could be a decent start. i would think that +/-5%ABV readings should be sufficient. You guys will have to figure out the conversions, scale factors and all the other varibles that come into play.... Hope this draws interest.

EDIT: To walk you through, the best way to do this is time the top-off of a capacitor through the solution. Wires doing this task should be approximately .8cm apart. I used moonshine and 80proof vodka. After all processing moonshine read = 132 proof (66%) and the vodka read at 81, 78 and 76 in repeated tests (40.5-38proof). This execution was sketchy and hurried. I am also not sure how to include the source files I made... so.... I think this won't meet the requirements. Oh well. I pretty much did it... although without much of a range of known solutions to test it. Ahh oh well, I tried at least.

I work as a software engineer. This is my first post and I am drunk. I drink alot. How else would I want to attempt this. For anyone who sees this, reads this far and has interest, I hope you try. I am personally, but its too early (as well as way too late with work in the AM) to know if it will conform to the measurement drift allowed by my stated limit. For any alcohol enthusiasts that find this, good luck. I am using a Stellaris driven setup guys. If anyone attempts this maybe, besides me, try to keep it simple. With how far I've gotten I am realizing that this is actually easier than it seems at first! Enjoy!

Note#1: First, hydrometer means alcoholometer and vice versa. Point is electrically measure alcohol content of some booze you got on hand. Also, spelling. I am buzzed to say the least.

Note#2: Knowledge of chemistry principles will help. Polar solvents and such have well documented properties if you know where to look. Sorry for any stupidity I might've rubbed off onto the idea... its just something that I really want to do!

Despite limited time tonight and impairment, I have made a fair amount of progress. Enjoy your night and thanks for your time.