Yahtzee is a game played with 5 dice and a score card. The object of the game is to get the best score. A turn consists of the following:
- Roll all of the dice.
- Keep as many of the dice as you want.
- Re-roll the dice you decide not to keep. Note that at any time if you like your hand you can stop rolling.
- Repeat step two and three. Note that you can throw away some of the dice that you previously kept.
- Now that you've had up to three rolls, record the resulting roll in a single place on your score card (scoring only applies to the final hand you keep).
Your score card is divided up as follows:
- 4 of a kind - 4 or more dice the same, scores the face value of ALL the dice.
- full house - 3 dice equal to each other with the other 2 dice equal to each other as well. Scores 25 points.
- small straight - Any 4 of the dice in consecutive order, scores 30 points.
- large straight - All 5 dice in consecutive order, scores 40 points.
- yahtzee - All 5 dice equal to each other, scores 50 points.
You are given a String rolls containing fifteen numbers, the first five of which are your first roll, and the next ten what you would get if you continued to roll in order. For instance, if input is "123456123456123" your first roll gives you "12345". If you keep the 1, 2, and 5, and reroll the other two your hand would now look like "12615". Now if you keep the two 1's and reroll the other three, your final hand would be "12314". You are to return the best possible score you can get.
|