|
1 | 1 | # Instructions
|
2 | 2 |
|
3 |
| -The dice game [Yacht][yacht] is from the same family as Poker Dice, Generala and particularly Yahtzee, of which it is a precursor. |
4 |
| -In the game, five dice are rolled and the result can be entered in any of twelve categories. |
5 |
| -The score of a throw of the dice depends on category chosen. |
| 3 | +Given five dice and a category, calculate the score of the dice for that category. |
6 | 4 |
|
7 |
| -## Scores in Yacht |
8 |
| - |
9 |
| -| Category | Score | Description | Example | |
10 |
| -| -------- | ----- | ----------- | ------- | |
11 |
| -| Ones | 1 × number of ones | Any combination | 1 1 1 4 5 scores 3 | |
12 |
| -| Twos | 2 × number of twos | Any combination | 2 2 3 4 5 scores 4 | |
13 |
| -| Threes | 3 × number of threes | Any combination | 3 3 3 3 3 scores 15 | |
14 |
| -| Fours | 4 × number of fours | Any combination | 1 2 3 3 5 scores 0 | |
15 |
| -| Fives | 5 × number of fives| Any combination | 5 1 5 2 5 scores 15 | |
16 |
| -| Sixes | 6 × number of sixes | Any combination | 2 3 4 5 6 scores 6 | |
17 |
| -| Full House | Total of the dice | Three of one number and two of another | 3 3 3 5 5 scores 19 | |
18 |
| -| Four of a Kind | Total of the four dice | At least four dice showing the same face | 4 4 4 4 6 scores 16 | |
19 |
| -| Little Straight | 30 points | 1-2-3-4-5 | 1 2 3 4 5 scores 30 | |
20 |
| -| Big Straight | 30 points | 2-3-4-5-6 | 2 3 4 5 6 scores 30 | |
21 |
| -| Choice | Sum of the dice | Any combination | 2 3 3 4 6 scores 18 | |
22 |
| -| Yacht | 50 points | All five dice showing the same face | 4 4 4 4 4 scores 50 | |
| 5 | +~~~~exercism/note |
| 6 | +You'll always be presented with five dice. |
| 7 | +Each dice's value will be between one and six inclusively. |
| 8 | +The dice may be unordered. |
| 9 | +~~~~ |
23 | 10 |
|
24 |
| -If the dice do not satisfy the requirements of a category, the score is zero. |
25 |
| -If, for example, *Four Of A Kind* is entered in the *Yacht* category, zero points are scored. |
26 |
| -A *Yacht* scores zero if entered in the *Full House* category. |
27 |
| - |
28 |
| -## Task |
| 11 | +## Scores in Yacht |
29 | 12 |
|
30 |
| -Given a list of values for five dice and a category, your solution should return the score of the dice for that category. |
31 |
| -If the dice do not satisfy the requirements of the category your solution should return 0. |
32 |
| -You can assume that five values will always be presented, and the value of each will be between one and six inclusively. |
33 |
| -You should not assume that the dice are ordered. |
| 13 | +| Category | Score | Description | Example | |
| 14 | +| --------------- | ---------------------- | ---------------------------------------- | ------------------- | |
| 15 | +| Ones | 1 × number of ones | Any combination | 1 1 1 4 5 scores 3 | |
| 16 | +| Twos | 2 × number of twos | Any combination | 2 2 3 4 5 scores 4 | |
| 17 | +| Threes | 3 × number of threes | Any combination | 3 3 3 3 3 scores 15 | |
| 18 | +| Fours | 4 × number of fours | Any combination | 1 2 3 3 5 scores 0 | |
| 19 | +| Fives | 5 × number of fives | Any combination | 5 1 5 2 5 scores 15 | |
| 20 | +| Sixes | 6 × number of sixes | Any combination | 2 3 4 5 6 scores 6 | |
| 21 | +| Full House | Total of the dice | Three of one number and two of another | 3 3 3 5 5 scores 19 | |
| 22 | +| Four of a Kind | Total of the four dice | At least four dice showing the same face | 4 4 4 4 6 scores 16 | |
| 23 | +| Little Straight | 30 points | 1-2-3-4-5 | 1 2 3 4 5 scores 30 | |
| 24 | +| Big Straight | 30 points | 2-3-4-5-6 | 2 3 4 5 6 scores 30 | |
| 25 | +| Choice | Sum of the dice | Any combination | 2 3 3 4 6 scores 18 | |
| 26 | +| Yacht | 50 points | All five dice showing the same face | 4 4 4 4 4 scores 50 | |
34 | 27 |
|
35 |
| -[yacht]: https://en.wikipedia.org/wiki/Yacht_(dice_game) |
| 28 | +If the dice do **not** satisfy the requirements of a category, the score is zero. |
| 29 | +If, for example, _Four Of A Kind_ is entered in the _Yacht_ category, zero points are scored. |
| 30 | +A _Yacht_ scores zero if entered in the _Full House_ category. |
0 commit comments