r/ProgrammingPrompts • u/schlendeus • Feb 14 '18
r/ProgrammingPrompts • u/heluva_guy • Apr 18 '16
Create vanilla js custom web components
Write a set of vanilla js custom web components that can be used as a tag on HTML (like clock, timer etc ) rather than updating the dom using jquery plugins , which decrease the beauty of code and increase maintainence.
r/ProgrammingPrompts • u/[deleted] • Apr 01 '16
[Medium] Cross product of a list of lists. The function should be able to handle any list size.
Given a list of size n, Write a program that returns all possible combination of elements contained in each list.
Example:
List A = "x, z"
List B = "a, b, c"
List C = "o, p"
Output:
x a o
x a p
x b o
x b p
.....
z c p
Order doesn't matter, but the hard part is: You can't use recursion.
r/ProgrammingPrompts • u/doekaschi • Aug 13 '15
[MEDIUM] Write a Program that can solve alphametics
Write a program that can solve alphametics. Alphametics are nothing else than equations, only with letters:
AA + BB = CC
in this case:
A = 1 B = 1 C = 1
so the solution is:
11 + 22 = 33
Also, one the same number can't be referred to by two or more letters, so:
A = 0 B = 0 C = 0
is not possible (even if it is correct)
Your job is to write a progam in which the user can input an alphametic (GUI or console, doesn't matter), and the program finds the right (or one of the right) solutions to math numbers to the letters so equation is correct.
r/ProgrammingPrompts • u/Weak_Ease9338 • Oct 30 '20
Creating a fake credit system for a school's project website.Need guidance
Hi yall. So as title say's I have created a game website. So I need to add some thing to it to look more realistic. So I have a question Can I do like fake credits system which grants like 500 like 'we happy your are signed in so here is your 500' and than I would create mini-games which costs like 50 to enter and play on website. Depending of score it would grant some more credits to persons account. So I need help or guidance from where to start. Any tips would be apprecianted. I can write codes in C++, mySQL, ,PHP , HTML, CSS, JAVASCRIPT. Keep in mind I know these language's in begginer level and I can read more on subject or something to learn much more to my requested topic . But main project is done throught PYTHON with FLASK and I can use any code language's I want to add in some thing to it. So if anyone have any tutorial links or experience in that or plan how to realise it. I would highly appreciate it. If anyone require's info on code or something from me feel free to ask and critise. Thank you in advance !
r/ProgrammingPrompts • u/Trader5050 • May 01 '20
How best to implement this?
Hi all!
I feel like this is a good prompt but also might help people think outside-the-box for a problem I have!
I'm in the military and we have a scheduling problem at my job that I believe can be solved via a relatively simple tool, but the concept could be difficult to implement and I'm looking for some ideas.
We have difficulty scheduling 100+ people with shifts, training, business trips, etc. Most people tend to use excel for this sort of thing but it's a massive amount of work and just not an ideal solution.
I'm looking to create a visual schedule of all personnel, laid out horizontally, that will block off dates with activities/etc. and allow for the input of new events, changing dates, colors for different type of activities, etc. I'd really like this to be able to create a "draft" schedule and also drag/drop items around on the schedule... i.e. much more dynamic than it is in a static excel sheet.
Here's the problem: being on a military network I can't just (1) run my own web server, (2) I have access to a limited set of tools (Microsoft Access/Excel/etc.), and (3) I don't believe going to a pre-built, paid solution that's hosted by a third-party will be approved.
(I know PHP/CSS/MySQL, Java, and have dabbled in some frameworks like CakePHP.)
Any thoughts?
Appreciate any feedback!
r/ProgrammingPrompts • u/Kxaos • Aug 26 '15
Write a pure toString() && toInteger()
Write your own toString(int number) and toInteger(string str) functions. you can't "include" or "import" or "using" anything. you can't use built-in functions Make them 100% pure ;) Good Luck!
My solution: ( C++ )
// Get the length of an integer
int length(int data,int len=0){return(!(data/10)?++len:length(data/10,++len));}
string toString(int num){
string str="";int temp;
for(int i=0;i<length(num);i++){
temp=num;for(int j=i;j<length(num)-1;j++)temp/=10;
str+=length(temp)>1?(temp-((temp/10)*10))+48:temp+48;}
return str;}
int toInteger(string str){
int total=0,temp=0;
for(int i=0;i<str.length();i++){
temp=str[i]>='0'&&str[i]<='9'?str[i]-48:0;
for(int j=i;j<str.length()-1;j++)temp*=10;
total+=temp;}
return total;}r/ProgrammingPrompts • u/Polishfreak19 • Dec 28 '18
Actor search
Hi reddit. So I have a programming question that I need help with. I'm writing an application in Javascript where I have to come up with a list of actors that starred in movies with both Keanu Reeves and Nicolas Cage but not necessarily at the same time but I'm not exactly sure where to start?
r/ProgrammingPrompts • u/deanmsands3 • Jun 07 '21
Write a network server that serves a SQLite database in your dominant language. Write a client in a different language.
r/ProgrammingPrompts • u/Polishfreak19 • Dec 31 '18
Six degrees of separation Javascript problem
As I haven't been successful, I'm asking if anyone has any ideas. I have to write a Javascript application which returns a list of actors that have been in both a movie with Keanu Reeves and Nicolas Cage. Sort of like a six degrees of separation. I have an API that I'm making a request to and I'm getting some data in return but I'm not exactly sure where to go from there?
r/ProgrammingPrompts • u/mrburrito2 • Feb 06 '15
Question: Was there a prompt here earlier that got deleted?
I believe I saw a prompt that said [Java] and had to do with finding different solutions to an equation with 9 variables. Does anyone have the post or the equation?
r/ProgrammingPrompts • u/[deleted] • May 31 '20
Do you have space-related prompts or challenges?
Hi, I'm quite into science and space and something related to that might be encouraging to keep on learning!
r/ProgrammingPrompts • u/normandantzig • Dec 06 '16
Strong Password Detection
Write a function that uses regular expressions to make sure the password string it is passed is strong. A strong password is defined as one that is at least eight characters long, contains both uppercase and lowercase characters, and has at least one digit. You may need to test the string against multiple regex patterns to validate its strength.
Source: AutomateTheBoringStuff
r/ProgrammingPrompts • u/deanmsands3 • May 01 '16
[Medium]Write a podcast ripper in C++
This is one of my favorite "learn a new language" projects: podcast rippers. The code outline is simple.
Read podcast feed URL from command-line.
Download the podcast feed.
Parse through the XML
Identify the elements holding the podcast URLs
Identify the filename to use
Download the podcast and save to file.
Rinse and repeat!
The tricky part is doing it in C++. Use whatever libraries you like (like libCURL and TinyXML) unless their stated purpose is to rip podcasts or the like.
Bonus Points if you write it in straight C.
r/ProgrammingPrompts • u/desrtfx • Mar 10 '14
Write an implementation of the Ship, Captain, Crew game
Ship, Captain, Crew is a simple dice game, often played at parties.
Here are the rules: http://en.wikipedia.org/wiki/Ship,_captain,_and_crew
The game should accept any number of players - with names.
[Optional:] Create some AI for computer players (also any number) with maybe different strategies.
r/ProgrammingPrompts • u/obviouslyCPTobvious • Mar 31 '14
Martyr2'S Mega Project Ideas List! - 125 Project Ideas
r/ProgrammingPrompts • u/desrtfx • Mar 05 '15
The Game of 21 aka Subtraction Game (or Nim)
The game of 21 is one of the oldest and simplest games known to mankind.
There are 21 tokens (matchsticks, pebbles, or any other small objects) on the table.
Each player can take 1, 2, or 3 tokens each move.
The player who has to take the last token loses (alternatively wins).
You should create the program for a game of 21 in a language of your choice according to the following specifications:
The game should be playable with either 2 players or against the computer
The program should handle the counting, win/lose evaluation and check that the players only make valid moves
The minimum computer player should take 1 to 3 pieces randomly
The program should alternate the starting player on each round
Overall winner should be who won best of 5 rounds (customizable)
There is no need for a real graphical interface, simple console will suffice, but a GUI is a nice optional touch.
Challenge:
Program a computer player that never loses. (It's definitely possible to win a game of 21 as either the first player or as the following player.)
Variants:
Make the initial quantity of tokens and the maximum number of tokens that can be taken per turn changeable.
Another, famous variant of 21 is known as "Nim" (or "Marienbad" from the movie "Last Year at Marienbad" from the year 1961)
In this variant, the tokens are arranged in 3 heaps of 3, 4, and 5 tokens.
Players may take any number of tokens from a single heap.
The player who has to take the last token wins (or loses - depending on the variant).
Again, the number of heaps and the numbers of tokens per heap can be made adjustable
This variant is also fully solved and can be played in such a way that any perfect player can always win.
r/ProgrammingPrompts • u/jirocket • Sep 02 '14
4 is the Magic Number
Before writing any code, you need to figure out the premise of the game!
ex 1.
eleven is six
six is three
three is five
five is four
4 is the magic number
ex 2.
one is three
three is five
five is four
4 is the magic number
When you've figured out the rules of the game, simulate it.
(You can also have your friends scratch their heads over this during car rides)
hint: I used a recursive function and a dictionary (as in python)
r/ProgrammingPrompts • u/king_of_the_universe • May 23 '14
Create a text adventure with simulation
Interactive text-based stories, where the magic happens in the head - not new. But I haven't seen one with a simulated world in the background yet.
This idea is for beginners and pros alike - just pick your level of complexity.
Example: "You are in a kitchen. You see a stove, a fridge, a ceiling lamp, a switch, and a sink. There is an open door to the north, a closed window to the west."
The objects in the room have properties, the room itself has an environmental situation (e.g. air pressure, smells, temperature), the player also has properties (e.g. when the light is low or the player is blind-folded, the data retrieved via the eyes is limited/removed, so the text is changed accordingly, all by procedure instead of manually typed!).
On every game turn, simulate(); is called on all existing objects in the game world. So, when you return to room X, the fruits in the bowl on the table might have become a little less fresh.
Some ideas:
The game could either be turn-based, like the classic ones, or it could be in real-time in 1-second-steps, and as soon as the player starts typing, the game is paused until the input line is empty again. Alternatively, the whole input could happen via dropdown-menus: The moment a menu is opened, the game is paused. I attempted this a little, works very well - there was an "exits" menu, a "you" menu, and an "objects" menu.
Simple "sound rendering": Sounds could be muffled or too silent to identify. One sound could be "drowned out" by another one, so that you e.g. have to turn off a washing machine to be able to hear/identify the person imprisoned behind the secret wall. One way to do this, for example, could be to describe the sounds a bit to the machine. http://en.wikipedia.org/wiki/Audio_frequency is an interesting resource for this. Based on it, one could describe with a boolean or double the significancy and volume of 4 or 5 frequency sections of the sound in question. This would allow to calculate how much a sound might be overridden by another one, to determine if it should be described to the player clearly, in a very coarse way that could be interpreted freely, or if the sound isn't described at all.
Simple "light rendering" - or should I call it "em radiation rendering"? http://en.wikipedia.org/wiki/Electromagnetic_spectrum Nuclear terrorism, here we come! (Hi FBI.)
Player and other beings could have rather complex and simulated stats, e.g. body temperature, hunger, weight, height, stance (Can you see the police car outside through the window while being bound on the floor?)
Talking about police: NPCs could gather information (with some Garbage Collection to prevent data overkill), so if you drive your van to the city park and abduct someone, the police might be able to browse the tree of available options/objects to pick up an informational trace and ultimately get to you. I know, totally insane, but I believe it's not impossible. On the other hand, during your next game, you might play a cop yourself! An open self-experience system?
Once you have a working system with rooms and some objects, start writing a world generator so that you have fun exploring your simulation while you're writing it. Tests will probably be pretty inspiring for the overall project.
Suggestions:
After a few attempts, I have figured out that the object model should use soft links, meaning that the objects should refer to each other via an ID number (e.g. 64 bit long), because ultimately you will face the beast that saving/loading is, and loading while related objects don't exist yet is a pain. Better just use soft links and look everything up in a manager class that also does the loading/saving.
Every object (hence the master class from which all object classes inherit) should have an inventory. You could add flags and checks for/against the player/simulation using it, but it's good if it exists. E.g. put an object into your mouth. Or define buildings by "house contains floors which contain apartments which contain rooms" etc.
Additionally, each object might have a variable list (in Java, it would probably be a HashMap<String, Object>), because that's again much easier to save/load than creating extra variables in each object and then having to deal with those.
If you want to make a toilet (or whatever other kind of world object), my attempts have shown that it's best to create a separate class for every kind of object instead of trying to build the omni-object.
Go crazy! E.g. in my realtime-attempt (Java) where input happened via dropdown menu, I made a toilet where you can lift/lower the lid and the seat (each pushing each other), you can flush, and you can abort the flushing which means that the next flush works right away but is shorter (the tank refills in realtime, the rest is logical - See the beauty of simulation versus just writing the story?). It's easy and fun to write world-objects like these, and they are easy to extend: Say, the toilet does not refill if the incoming water pipe is turned off. Of course you still have a free flush. Alternatively, you might be imprisoned and might need water. Hard choices have to be made, especially if you also simulate bowel movements.
Again, go crazy: It's a text adventure system! Well, you can't just make up anything, because you have to give it some reality via simulation, but otherwise: Sky's the limit! Processing time is not an issue. Why shouldn't a turn take a few seconds? Do all the things you wished were in your favorite 3D action adventure game, but they didn't put it in because of development constraints, marketing, or simply because everything at once can't be done on today's PCs. But I double-dare you: DON'T fuck up the FoV!
r/ProgrammingPrompts • u/opensourcecolumbus • Jun 08 '21
Build a reddit search system
Build a simpler version of reddit search system that will take a query as input and return the matching post results.
Some instructions and examples are given below to get started (You can use any language you want. Instructions use javascript style just for representation)
// 1. Create some dummy data similar to reddit text posts
post1 = { title: 'Build a reddit search system', description: "Build a simpler version of reddit.....", id: 1 }
// 2. Store all the data in one data structures e.g. array
postArray = [post1, post2, ....]
// 3. Index postArray data for fast search (any changes you want to make for quick and better search. Google about "search indexing" or watch the video I shared.
function indexData(postArray){...}
// 4. Create search function that will print the returning posts
function search(query){...}
// 5. Bonus: highlight the matching linesYou can learn about key terms used in search systems using this video on how google search works. I will also build it and share my work at the end of this week.
r/ProgrammingPrompts • u/Valianttheywere • Nov 15 '20
An Educational Game: Tribe
The Gameboard. We have Africa divided into assorted zones along with three possible start points.
So the game is for 2-3 players.
Each player gets a language development card deck.
Game play: each player rolls 1d6. This is the number of starting cards you can draw from your language development deck.
The name of your tribe is made from this initial alphabet.
Your first game piece is on the start point.
What happens during a turn?
step 1: Turn Option
A. Move an existing piece to an adjacent location.
or
B. Attack a rival on an adjacent location. This is a massacre and you take the location from your rival.
Or
C. Spawn a new piece from your start location-only if you have an existing piece on start location. The new piece is moved into an empty adjacent location.
Or
D. develop language. Roll 1d6. Draw new alphabet cards from your language deck equal in number.
Step 2: Check language Development. If you can spell a word from your drawn alphabet- words like farming, pyramid, canoe, boat, then your tribe has developed these. If you can spell canoe and have secured a location next to madagascar, you can move a game piece to the island next turn. If you can spell boat you can sail from any coastal location to madagascar next turn.
As your tribe occupies the map, in conflict with your opponent(s) the game continues until you gain all 26 letters of the alphabet before your rival, or wipe out your rival.
Its just a little educational game I created for public domain as an outflow of my linguistic archaeology research. So feel free to turn it into a billion dollar online franchise.
r/ProgrammingPrompts • u/Chemical_Studios • Mar 08 '14
Very simple procedurally generated map
I think this could be a good exercise/project for anyone!
What is it?
In this project the programmer will create a "map" which will be printed out to the console. This map can be any size the programmer wants, however it needs to be different every single run.
Rules (optional)
There should be multiple different tiles with their own rules and symbolized by a unique character (chosen by the programmer):
Ground - The base of the map, no special rules
Water - Should form in "lake(s)"
House - Should only form on ground tiles
Boat - Should only form on water, if one of the surrounding tiles are a house tile
Example outputs
In this case, tiles are represented as:
Ground - "#"
Water - "~"
House - "■"
Boat - "U"
10x5 Map:
##########
##~■#■~###
#~~~■~~~##
##U■~~~###
#####~####20x10 Map:
########~###########
#######~~~##########
########~###########
####################
#####~##############
####~~~■############
##■##~##############
###■################
###############■###■
####################r/ProgrammingPrompts • u/desrtfx • Jul 07 '16
Give new life to an old game
Hello everybody!
It's been a fairly long time, but here is another challenge for you.
The rules are:
Any language (except the original BASIC or PC-Basic) allowed
Result should match the original as closely as possible
And here is the challenge:
Take the source-code from the game "The Oregon Trail" and convert it into a language of your choice.
The source code that acts as reference for this project is here.
The purpose of this Programming Prompt is to learn how to read and work with legacy code (in a language you probably don't know) and to convert this code into a more modern language.
Good luck & have fun!
r/ProgrammingPrompts • u/philalether • Jun 11 '19
Make a tool that scrapes the change-logs of a wikimedia image to make an animated gif
I’m looking around the web for an animated gif of the maps of LGBTQ rights around the world, found here:
Disappointed that such a thing doesn’t seem to exist, I thought it would be great to have a software tool to automatically create this. And if one were making such a tool, it might as well work for any Wikimedia image with a change history.
(And I guarantee that this particular LGBTQ rights map animated gif would be front page material on /r/dataisbeautiful or /r/MapPorn.)
If anyone does decide to make this tool, please let me know by tagging my username when you release it!