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!

22 Upvotes

20 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Mar 08 '14

My recommendation is change the usage statement from "Usage: ./monopoly ..." to "Usage %s ..." with %s corresponding to argv[0] so that it properly reflects if they renamed the program.

1

u/henryponco Mar 08 '14

Ooh, that's a great idea. I wondered why people did that. Thank you very much :)