r/ProgrammingPrompts • u/quadamp • Mar 29 '16
[Easy] Make a simple password generator
Make a password generator that generates a random password of desired length specified by user input.
For example:
Enter desired password length>> 7
hY@rSdA
r/ProgrammingPrompts • u/quadamp • Mar 29 '16
Make a password generator that generates a random password of desired length specified by user input.
For example:
Enter desired password length>> 7
hY@rSdA
r/ProgrammingPrompts • u/CzechTimesStayFly • Aug 19 '16
Hi everyone. So I work for a company and in my team we are like 20 people, each one with different skills (we also share some of them).
To give you and example >
Guy 1 has A,B,C,F skills
Guy 2 has A,B,E,D skills
Guy 3 has C,D,F,A skills
We are about 20 and when we have lunch breaks, we split in 2 teams. I would like to create a script that takes all this data, compares it and returns the users split in 2 teams while the skills are all covered for both hours.
Counting that sometimes not everyone is in the office I was thinking I should start by creating some sort of database where everyone has his own skills assigned and in the morning when I have to create the lunch schedule I add the names of the people that are present and the script runs only taking in account this stored data.
Now I'm not a programming genius but I would like to make this automatically run by a script without having to check every morning and comparing all the skills and shit.
I was thinking Excel to store information ans SQL to extract them?
I don't really know where to start. I don't want you guys to make it for me. Just asking which kind of language should I use and what should I focus on.
Also there are a couple of other variables to be taken in account but lets see if someone reacts to this post first and in case this goes well I will also put more info.
Thanks a lot!
r/ProgrammingPrompts • u/Zerothehero-0 • Jul 07 '17
My idea is to create a code/program that simulates the evolution of alphabets and letters over time in terms of shape, sound, and linguistical use in a language. I imagine the program to take in an input of a 64x64 pixel drawing of the letter/glyph and have the code alter it slightly overtime by adding pixels, connecting gaps, deleting pixels, rotating, etc. If anybody has any idea how to go about writing this program, please let me know and/or give me any sort of feedback about my idea for this code.
r/ProgrammingPrompts • u/[deleted] • Mar 09 '14
I challenge y'all to make a set of virtual DnD dice of which you can decided how many sides the dice have. This one should be really simple though there's plenty of room for branching off and being as thorough as you'd like (ASCII art title, keep track of each player's rolls and keep track of them by name etc.).
r/ProgrammingPrompts • u/Guomindang • Jan 31 '15
Here is an interesting project for those of you programming in Windows. The goal is to create a simple musical notation processor which you can use to amuse or annoy your friends. I've written this for the benefit of beginners who are tired of manipulating characters.
Your computer has an internal speaker that can only emit a beep, the loudness of which is independent of the volume setting. However, by specifying its pitch and length, we can use it to generate music. For example,
This project will require the use of two functions that are native to Windows—beep and sleep. If you are not using Microsoft Visual Studio, you will need to write,
#include <windows.h>beep takes two arguments—frequency and duration.sleep takes one argument—duration.
Frequency is measured in hertz and must be an integer from 37 to 32,767. Other values will result in a crash.
Duration is measured in milliseconds.
For example,
#include <windows.h>
int main(void)
{ beep(261, 500);
sleep(1500);
}This program will beep at 261 Hz for 500 ms, pause for 1,500 ms, then terminate.
Practice
Create a generative music program by using random numbers as frequencies and durations. Make sure to keep the durations short or else you will have to endure a lengthy cacophony.
A basic understanding of musical notation is recommended. Here are some important references.
It would be tedious to write the exact frequency and duration of every note in hertz and milliseconds. Fortunately, there exists a formula which converts the position of a note on a standard piano into its frequency.
f(n) = 2^((n - 49) / 12) * 440 HzProblem 1
Implement a function that converts the position of a note into its corresponding frequency. For example, 40 corresponds to 261 Hz.
Although we could just hard code the music, our program will be far more usable if it can read the music from a file. The next problems will require you to design a notation for this purpose.
Problem 2
Implement a function that converts the name of a note into its corresponding position. For example, C4 corresponds to 40, C4♯ and D4♭ correspond to 41, D4 corresponds to 42, et cetera.
Problem 3
Implement a function that converts a note value into its corresponding duration. For example, given a tempo of 120 beats per minute and a beat unit of 4, the quarter note corresponds to 500 ms, the half note corresponds to 1000 ms, the whole note corresponds to 2000 ms, et cetera. The tempo and beat unit should be variable.
Problem 4
Implement a parser that can read your notation from a file.
Done? Test it out by transcribing Flight of the Bumblebee and playing it. Adjust the tempo.
Intermediate Challenges
Reduce redundant notation. If a note is of the same duration or octave as the note before it, then its duration or octave can probably be omitted.
Implement key signature to indicate that certain notes are to be automatically flattened or sharpened. This will also require implementing the [natural accidental](http://en.wikipedia.org/wiki/Natural_(music)).
Implement arpeggio.
Implement glissando.
Implement repetition.
Advanced Challenges
Implement ABC notation.
Implement graphical representation.
r/ProgrammingPrompts • u/ggleblanc • Oct 16 '15
Create a bowling score from an input string of roll marks.
Here's what roll marks look like:
"X-/X5-8/9-X811-4/X"
"9/8/9/8/9/8/9/8/9/81"
"9/8/9/8/9/8/9/8/9/8/9"
"XXXXXXXXXX9/"
"XXXXXXXXXXXX"The roll mark strings above are complete representations of a bowling game. If you create your own test strings, make sure that they are complete.
Here's a web page describing how to score a bowling game. Your application does not have to deal with fouls (F) or splits (S).
Your task is to produce something similar to the following output:
---------------------------------------------------
| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|
---------------------------------------------------
| X| -/| X| 5-| 8/| 9-| X| 81| 1-| 4/X|
| 20| 40| 55| 60| 79| 88| 107| 116| 117| 137|
---------------------------------------------------
---------------------------------------------------
| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|
---------------------------------------------------
| 9/| 8/| 9/| 8/| 9/| 8/| 9/| 8/| 9/| 81 |
| 18| 37| 55| 74| 92| 111| 129| 148| 166| 175|
---------------------------------------------------
---------------------------------------------------
| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|
---------------------------------------------------
| 9/| 8/| 9/| 8/| 9/| 8/| 9/| 8/| 9/| 8/9|
| 18| 37| 55| 74| 92| 111| 129| 148| 166| 185|
---------------------------------------------------
---------------------------------------------------
| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|
---------------------------------------------------
| X| X| X| X| X| X| X| X| X| X9/|
| 30| 60| 90| 120| 150| 180| 210| 240| 269| 289|
---------------------------------------------------
---------------------------------------------------
| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|
---------------------------------------------------
| X| X| X| X| X| X| X| X| X| XXX|
| 30| 60| 90| 120| 150| 180| 210| 240| 270| 300|
---------------------------------------------------Your output doesn't have to match my output character for character. You have to produce the game score. Producing the frame scores help with debugging.
The reason this is an interesting challenge is because of the number of corner cases or edge cases inherent in such a simple problem description.
Your application will probably not be short. That's OK. Just make sure it's correct.
I wrote this with Java. My version is 210 lines long. I'll post it in a week or so.
r/ProgrammingPrompts • u/deanmsands3 • Jun 14 '18
Back in the Mode 13h days, the fire routine used to be one of the fun "first projects" for people playing with graphics. A line of random data would be generated and then smoothed upward. The numbers would correspond to a palette of available colors. An extra vertical bump would give the flame a smoother, less smoky look.
But that's too easy. Let's do it in Text mode.
In text you have to set the Foreground color, the Background color, the Attribute (blinking, hi-intensity/bright) and then actual character.
You can either use a portable library like NCurses or the OS console API (for example: https://docs.microsoft.com/en-us/windows/console/console-reference ). Escape codes will maybe work if you're using Linux, but not Windows.
If you post your code, make sure to list which OS you're using.
Happy programming!
r/ProgrammingPrompts • u/dustinpdx • Sep 19 '22
MVP would be a simple two-round runoff model.
A stretch goal would be to be able to select from different types of runoff voting models.
This would also be an ideal next-step after finishing the Django tutorial which includes a basic poll app.
References:
https://en.wikipedia.org/wiki/Runoff_voting
https://docs.djangoproject.com/en/4.1/intro/tutorial01/
r/ProgrammingPrompts • u/Amster2 • Feb 02 '24
Extra points: It should look like it does something sensible, and not random bit managing, at first glance you would expect something, but something else happens. The ideia is not to make the code unreadable, but "easily-wrongly-readeable". I don't want to do anything shady - it's to teach a few friends about code readability. Thanks for any effort"
r/ProgrammingPrompts • u/desrtfx • Dec 02 '15
r/ProgrammingPrompts • u/XardasLord • Jun 15 '19
Hi there!
As you probably saw this is my very first post on Reddit :)
But let's back to the main topic here which is my idea for an application - "Smart Fridge" (this is only idea for a name). So, everything here is only an idea, but I really would like to get a feedback from you guys - what you think about this idea, etc.
----------------------------------------------------------------------------------------------------------------------------------------------------
For who?
Application is dedicated for all people who have a fridge at home.
Problem to solve?
This situation very often happens - you are in a shop but you cannot remember if you still have a milk (or some other product) in your fridge.
Why this application would be useful?
Application for user would be available via smartfon/web (firstly web application and android app later in the future). Application would show all scanned products which are available in your fridge in real time. So when you would be in a shop you can just open application/web and see what you have in a fridge available.
How would it work?
I thought about a Raspberry Pi + some mini barcode scanner module. This computer would be installed inside the fridge. When you will be put a new product into a fridge you will have to scan the barcode of this product before put into. When barcode is scanned the Raspberry Pi would communicate with the API that product with this barcode has been put into a fridge and The API would do the necessary logic. The same thing would happen if "user" is going to get some product from the fridge, he would has to scan the barcode again (maybe some switch somewhere to inform that product is getting from the fridge and not put into - this is a problem to discuss).
Pros?
Product that are in a fridge are available online
For sure this would be a cheaper solution instead of buying some fridge with cameras inside (very expensive now)
This solution would be available for every fridge at home (just need some space to install Raspberry PI inside)
Cons?
Of course the biggest disadvantage seems to be requirement to scan barcode before put/get product into/from the fridge.
Raspberry PI inside the fridge will not propably looks good
----------------------------------------------------------------------------------------------------------------------------------------------------
What do you think guys about this idea? I would be very grateful for you opinion and feedback :)
r/ProgrammingPrompts • u/[deleted] • Jul 28 '16
Fischerrandom is chess with all the back rank pieces all jumbled and scrambled and crazy like. The only three rules are that the king has to be between the rooks, the bishops must be on opposite colored squares, and the two sides have to be exactly symmetrically the same! Make the output something like "RBNNKRQB" indicating the white back rank. You dont need the black because it is just a mirror of white on the other side of the board. If you wanted to get real fancy you could associate each value with a picture of the corresponding piece and output a fancy piece array. *edit added rule about opposite colored bishops
r/ProgrammingPrompts • u/desrtfx • Nov 09 '14
I know, it's one of the most common programming tasks given (and one ofthe most implemented programs), but let's mention it here again.
Write an implementation of the Hangman game in the language of your choice.
+----------+
| / |
| / (-_-)
|/ |
| /|\
| / | \
| |
| / \
| / \
|
------+-----------------I've chosen the above shape to be the display. (I kept it deliberately simple without Unicode characters.) This gives a total of 10 wrong letters before the game is over.
The User interface can be simple terminal or a GUI of you like.
Minimum requirements:
Use a wordlist file (some links supplied at the end of this post)
Allow the user to select certain minimum and maximum word lengths between 7 and 15 characters and use only words of this length
Handle the Game loop and display the results
Display "_" (underscores) for each obscured (not yet guessed) letter
Track already guessed letters and warn the user about duplicate guesses (don't add them to fail/right again)
If the user guesses a correct character, all instances of the character in the word should be opened
Optional features:
Allow the user to set the wordlist file
Allow the user to edit the (or create their own) wordlist file
Allow user vs. user play (one user enters a word which is compared against the wordlist), the other user guesses. Next round, the roles are reversed.
The steps for each failure
The drawing starts with the bottom only:
------+-----------------Then the vertical column should be displayed:
+
|
|
|
|
|
|
|
|
|
------+-----------------Then the horizontal hoist beam:
+----------+
|
|
|
|
|
|
|
|
|
------+-----------------The reinforcement follows:
+----------+
| /
| /
|/
|
|
|
|
|
|
------+-----------------The head on the rope:
+----------+
| / |
| / (-_-)
|/
|
|
|
|
|
|
------+-----------------The body dangling:
+----------+
| / |
| / (-_-)
|/ |
| |
| |
| |
|
|
|
------+-----------------With one hand:
+----------+
| / |
| / (-_-)
|/ |
| /|
| / |
| |
|
|
|
------+-----------------With both hands:
+----------+
| / |
| / (-_-)
|/ |
| /|\
| / | \
| |
|
|
|
------+-----------------With one leg:
+----------+
| / |
| / (-_-)
|/ |
| /|\
| / | \
| |
| /
| /
|
------+-----------------Game over:
+----------+
| / |
| / (-_-)
|/ |
| /|\
| / | \
| |
| / \
| / \
|
------+-----------------Wordlist links
r/ProgrammingPrompts • u/[deleted] • Jul 26 '17
Not sure if I'm living in cuckoo land here or if this is actually a viable project that could take off. I was wondering what people would think of an app extension that, when you hover over the link with your cursor, would open the link as a window next to the cursor. This way, you could hover over a link on twitter, and read a longer-than-144-character post on twitter right next to the cursor without leaving the site at all. Thus, people can make longer twitter posts. Think bit.ly but specifically for making longer twitter messages.
How could it be done? I was considering making something like this as a small project in Javascript and upload it as a Chrome app.
r/ProgrammingPrompts • u/[deleted] • Feb 27 '17
If Java isn't your cup of tea, feel free to use any other object oriented language.
The goal is to make an RPG that continues playing, spawning battles and item drops randomly (enemies increase gradually in difficulty.) You should have the following attributes to your character: Name, attack, defense, HP, mana, stamina, and xp.
Challenges: Come up with a way to increase character level, each level up increasing an attribute and increasing xp needed for next level up.
Enemies should be objects too. They should get more difficult as the game progresses.
Items should drop randomly from enemies.
Have any more challenges? Comment below. I am working on this program myself and would like to hear suggestions for challenges!
r/ProgrammingPrompts • u/desrtfx • Nov 10 '14
This Programming Prompt is only part of a bigger idea.
In the near future, I am planning to post a series of dice games as programming prompts.
To make the development of the future dice games easier, I ask that you make a library, class, template, module, framework (whatever you want to call it) to handle dice.
Use a programming language of your choice
Start by simulating a single n-sided die
The constructor (or equivalent in the language of your choice) of the die should take the number of sides as a parameter. A no-parameter constructor should default to a 6-sided die
A die can be rolled and returns the result in the range from 1 to n inclusive (of course, the returned values are whole numbers, no decimals)
A die can be held so that it always returns the result of the last roll before the die was held.
It should be possible to query the hold state of a die.
It should be possible to always query the result of the last roll without re-rolling.
Use the random feature of the language of your choice, no need to invent your own random algorithm (but you can do so, if you insist).
There should be a nice, textual presentation of the roll result.
Once the single die simulation is complete, create a dicebag consisting of several dice.
Allow for non-numeric die sides (a two-sided die could have "Head" and "Tail" on the sides, a Fate die has "+", "-", and " " (blank) on it's sides, etc.)
Allow for a die-color (in text only "Red", "Black", etc.)
A default dicebag does not contain any dice but can hold any number of dice.
It should be possible to add and remove dice at any time from the dicebag.
Allow adding of multiple dice with the same sides, or with different sides.
Allow adding of previously created "Die" objects.
the dicebag can hold m dice which all can have different sides (RPG-dice)
To achieve this, use the standard notation for dice which is mdn where m is the number of dice and n represents the sides of the dice. (5d6 would mean 5 6-sided dice) - The more advanced form including arithmetic operators is not necessary. (for example 5d6 + 3d4)
It should be possible to roll all dice (roll result as an array) or roll any specific die(roll result as an integer)
It should be possible to get the last-roll results for all dice or for any specific die (see above)
It should be possible to query the sum of the last-roll
It should be possible to set each die on hold, or to release each die.
It should be possible to query the hold state of all dice or of any single die.
There should be a nice, textual presentation of the roll results (I envisioned something like "1-4-6" (to display a 3d6 roll)
There should also be a way to retrieve the amount of dice in the dicebag.
As a final result, you should have a re-usable piece of code for many different dice games.
If anybody has reasonable suggestions, please state them in the comments and I will be happy to add them to this post.
Edit: The goal of this post is to have standard die and dicebag libraries for as many languages as possible.
Edit #2:
Code can be uploaded either directly in the comment (but this is only for very short code - less than 50 lines or so), or, commonly pastebin.com is used for code that fits in a single file, for code in multiple files, gist.github.com is commonly used.
Here is a guide on code posting in reddit - it's for Java, but applies to all languages
Edit #3:
Javascript by /u/Deathbyceiling
Racket by /u/DanielSherlock
Java (no Dicebag yet) by /u/seronis
r/ProgrammingPrompts • u/desrtfx • Nov 04 '14
Nearly everybody knows the game of battleships.
The game board is a 10 by 10 matrix for each player with a second 10 by 10 matrix to track the player's shots. The matrix is numbered (0 to 9) across the vertical axis and uses letters across the horizontal axis (A to J).
Each player places a number of ships on the game board. The ships can be placed vertically or horizontally, but not diagonally.
Optional rule: Ships must not be placed adjacent to other ships. At least a single square must be empty between the ships. This rule applies also to corners.
The ships in detail are:
4 submarines (1 square each)
3 destroyers (2 squares each)
2 cruisers (3 squares each)
1 battleship (4 squares)
The players take turns shooting at squares.
Shots are taken in the form of Strings consisting of 2 characters. First character represents the Column (letters A to J) and second character is the row number (0 to 9).
The other player then answers with "hit" or "miss".
In case of a "hit", the current player gets another shot.
In case of a "miss", the other player gets to shoot.
A player can shoot until he misses.
If a ship is destroyed, the reporting player reports "sunken" in addition to the "hit" report.
If all ships of a player are destroyed, this player loses the game.
The programming task is to create a battleship game.
As a basic goal it should:
Single player vs computer - single computer strategy
provide and display the two matrixes for the player
handle setting up of the ships (optionally including the optional rule from above)
create a computer player that competes against the human
handle the game loop (turns)
decide winning conditions
display a simple help screen with the basic rules
provide a GUI for input (can be textual, or graphical, but when the GUI is graphical, it should also respond to mouse clicks for shots).
Single player vs computer with different computer strategies
create different computer strategies to place the shots
Computer vs Computer with different strategies
Allow for a computer against computer game and display each round from the perspective of one of the computers
Multiplayer over LAN
allow two players to compete against each other over LAN connection
either player only sees their boards
Game recording
create a system to record the games (board setup for both players, moves of the players)
Game saving
Allow interruption of a human vs computer game at any point and save the game state to resume later.
Different ship types and numbers
Allow to alter the composition of the fleet (the number, naming, and sizes of the ships). The fleet must be identical for both players.
Other optional rules as described in the Wikipedia article linked on top
Use a programming language of your choice. It's also allowed to create a browser / server based version of the game.
Most important:
r/ProgrammingPrompts • u/hxnd126 • Mar 04 '20
Hi Guys! I’m a freshman and I’m looking to take part in my school’s optional self directed development project during the summer. I will have to create a web application with a database backend as part of the project. Can I have ideas on what I can develop that would meet the requirements?
r/ProgrammingPrompts • u/FlamingSnipers • Feb 11 '16
Write a program that takes in a string from the user (or if you want, a file!) and prints all the characters' ascii values summed up to the user.
For Example: The above paragraph's ascii sum is 13,156
Edit: It is actually 13,124 thanks /u/Answers_With_Java, I ran my program again and I got that as well, I dunno why I wrote 13,156
r/ProgrammingPrompts • u/[deleted] • Jul 16 '15
Convert currency using command line arguments
Argument format should be currency amount newcurrency
E.g.
Convert USD 100 GBP
Should convert 100 dollars into pounds and print the result
Must include a minimum of 3 different currencies
Bonus points: add another argument which takes a filename and saves the result in a text file of that name
r/ProgrammingPrompts • u/[deleted] • Jul 06 '15
Ever use Git, Mercurial, CVS, or Subversion? Of course you have. For this project, I think it would be fun to do a very basic version control system (from command line). It can be as simple as 'copy the entire folder' to as complex as you want. Let's keep it minimal - maybe bonus points if it's under 500 characters?
r/ProgrammingPrompts • u/DeanMcGintySandsIII • May 14 '24
I thought of this back when walking my dogs at my parents' mini-ranch.
Suppose we have a human walking two dogs. One is a slower bigger dog. The other is a faster smaller dog. The human is obviously the biggest and slowest. The human wants to walk the dogs in a wide circle (or whatever path you like) but the dogs keep tugging in all different directions.
Pick weights for all three. Maybe 60kg (for the human), 10kg (little dog), 25kg (bigger dog).
Pick lengths for the dog leashes. Maybe 2 meters each.
Plot or animate the three (circles or dots are fine) attempting to walk a circular path.
Or just plot the human getting dragged in whatever path the two dogs choose.
Some things to consider:
A dog will only exert force on the human if their leash is fully extended.
Both dogs will exert a different force based on their weight and speed.
The dogs will wander in random directions for random lengths of time.
r/ProgrammingPrompts • u/desrtfx • Dec 01 '14
This time it's going to be a quick and simple prompt.
The aim of the game is to roll the highest house number.
To achieve this goal, each player rolls a single six-sided die three times. After each roll the player decides where to put the roll result. The roll result can be placed in either the hundreds, the tens, or the ones position. Each position can only be filled once and changing one's mind is not possible.
The game is played with a single six-sided die
Each player rolls 3 times
After each roll the player has to decide where to put the roll result.
There are three positions where the roll result can be placed: ones, tens, and hundreds.
Each position can only be filled once
After the three rolls, the final house number is written down.
The highest result wins the round.
If there is a draw, all players with the same result score.
The highest possible house number is 666 and the lowest possible is 111.
Write a program to simulate the game of house numbers
Allow any number of human players to play
Allow any number of rounds to be played
The computer should do the dice rolling
The users should decide where to place the die after each roll
The computer should declare the round winner after each round
The computer should track score of the round winnings and of the roll results of each round for each player
The computer should declare an overall winner by round wins and a score winner by highest total score
Lowest house number wins the round, lowest overall score is the score winner
Alternating rounds: First round plays high house number, second round plays low house number, next one high, and so on.
+A single roll result may be flipped. I.e.: If the player rolls a "1" during a high house number round, they may flip the die to change the roll result to a "6". The opposite die sides are: 1-6, 2-5, 3-4.
Allow for computer players with varying strategies
r/ProgrammingPrompts • u/wlingke • Mar 07 '17
I wrote a fun coding challenge recently: http://dev.getethos.com.
There's a few different steps but see if you can get to the end. Understanding of web is needed for part 1, and understanding of networking is needed for part 2.
Please don't spoil!