The three rules of Ruby Q.:
Please do not post any solutions or spoiler discussion for this
quiz until 48 hours have elapsed from the time this message was
Support Ruby Q. by submitting ideas and responses
as often as you can!
Suggestion: A [QUIZ] in the subject of emails about the problem
helps everyone on Ruby T. follow the discussion. Please reply to
the original quiz message, if you can.
RSS Feed: http://rubyquiz.strd6.com/quizzes.rss
One Die Game (#203)
This week’s quiz was submitted by Siep K. through the
suggestions page http://rubyquiz.strd6.com/suggestions.
Imagine a two player game with the following rules:
- Playing material: 1 ordinary die; opposing sides sum up to 7.
- The first move consists of the first player rolling the die and
initializing the total to the amount on the face shown.
- All further moves consist of turning the die one quarter and adding
the face value of the new side to the current total. Example: If the
die is facing 2 after the initial throw, then possible moves are 1,3,4
and 6, with totals 3,5,6 and 8.
- A player wins when that player’s move results in a total of 31.
- A player loses when that player overshoots 31.
Let’s say it’s your turn. The current total is 24 and the die is
facing 3. You can win by turning the die to face 6, totaling 30. Your
opponent cannot play 1 because it’s at the bottom of the die, so he is
forced to overshoot the goal of 31.
Build a program which plays this game against a human opponent and
blunders occasionally (to keep it fun).
P.S. I did not invent this game; I’m pretty sure I found this game in
a chapter about nim-like games1 in one of Martin Gardner’s books.