[QUIZ] One Die Game (#203)

From: Mark W.
Sent on: Friday, May 1, 2009 12:22 PM
Good afternoon, Ruby People.

I think I may have missed the last couple quizzes...they've shown up a
little later than usual, then it's Friday afternoon, then the weekend
comes, blah blah blah...

Anyway, here's the latest quiz.  As always, hold your answers until Monday.

Have a great weekend,

Mark

-=-=-=-=-=-=-=-=-=-=­-=-=-=-=-=-=-=-=-=-=­-=-=-=-=-=-=-=-=-=-=­-=-=-=-=-

## One Die Game (#203)

Hej Rubyists,

This week's quiz was submitted by Siep Korteling through the
suggestions page <http://rubyquiz.s...;­.

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 games[1] in one of Martin Gardner's books.

[1]: http://en.wikiped...­

Have Fun!
-- 
-Daniel
http://rubyquiz.s...­

Our Sponsors

  • Josh Miller

    I pay for the Meetup, but beer is on you.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy