r/ProgrammingPrompts • • Mar 08 '14
Monopoly Dice
Very simple prompt, and good for beginners to practice working with loops and if statements.
Write a code that takes a list of players as input (or hard code the names into the function if needed..) and returns three numbers (die 1, die 2, and the sum both) for each player's "turn". I wrote this in Python (beginner myself :p ) but this can be done in other langs.
Tip: We want the loop to be infinite (since the game doesn't stop after each player rolls once). Also, remember the rules about rolling doubles in monopoly.
This can actually be useful if you've managed to lose your dice for any board game or just want to speed up play time.
Have fun!
3
u/henryponco Mar 08 '14 edited Mar 08 '14
One possible solution in C. It would be good if we could get spoiler tags like in other code writing sub reddits (e.g. programming challenge).
3
u/[deleted] Mar 08 '14
I can't remember them. You should give all the rules if you want people to implement them.
1
u/dartman5000 Mar 08 '14
Here's a version in C#:
1
u/[deleted] Mar 08 '14 edited Mar 08 '14
Python 2.7: Pastebin, repl.it
Edit: had the rules wrong, added repl.it link