Skip to content

Commit f029f7f

Browse files
committed
new exercise: yacht
1 parent 8b0d862 commit f029f7f

13 files changed

+916
-48
lines changed

config.json

+56-48
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,20 @@
128128
"difficulty": 2
129129
},
130130
{
131-
"slug": "bob",
132-
"name": "Bob",
133-
"uuid": "86d6375c-d791-431b-8440-d47fe31d48a5",
134-
"practices": [],
135-
"prerequisites": [],
136-
"difficulty": 3
137-
},
138-
{
139-
"slug": "twelve-days",
140-
"name": "Twelve Days",
141-
"uuid": "fd218a7d-3c39-473b-a71b-ff984ea58b86",
131+
"slug": "clock",
132+
"name": "Clock",
133+
"uuid": "a8a3657a-b490-4af8-be28-ac5df2c3f43b",
142134
"practices": [],
143135
"prerequisites": [],
144-
"difficulty": 5
136+
"difficulty": 2
145137
},
146138
{
147-
"slug": "house",
148-
"name": "House",
149-
"uuid": "9b389aab-2d46-4187-bb01-c107b9e4199b",
139+
"slug": "bob",
140+
"name": "Bob",
141+
"uuid": "86d6375c-d791-431b-8440-d47fe31d48a5",
150142
"practices": [],
151143
"prerequisites": [],
152-
"difficulty": 5
144+
"difficulty": 3
153145
},
154146
{
155147
"slug": "collatz-conjecture",
@@ -159,14 +151,6 @@
159151
"prerequisites": [],
160152
"difficulty": 3
161153
},
162-
{
163-
"slug": "complex-numbers",
164-
"name": "Complex Numbers",
165-
"uuid": "5591f4e1-6f72-415e-a789-12eebd712f9a",
166-
"practices": [],
167-
"prerequisites": [],
168-
"difficulty": 8
169-
},
170154
{
171155
"slug": "darts",
172156
"name": "Darts",
@@ -319,6 +303,22 @@
319303
"prerequisites": [],
320304
"difficulty": 4
321305
},
306+
{
307+
"slug": "twelve-days",
308+
"name": "Twelve Days",
309+
"uuid": "fd218a7d-3c39-473b-a71b-ff984ea58b86",
310+
"practices": [],
311+
"prerequisites": [],
312+
"difficulty": 5
313+
},
314+
{
315+
"slug": "house",
316+
"name": "House",
317+
"uuid": "9b389aab-2d46-4187-bb01-c107b9e4199b",
318+
"practices": [],
319+
"prerequisites": [],
320+
"difficulty": 5
321+
},
322322
{
323323
"slug": "all-your-base",
324324
"name": "All Your Base",
@@ -367,6 +367,22 @@
367367
"prerequisites": [],
368368
"difficulty": 5
369369
},
370+
{
371+
"slug": "yacht",
372+
"name": "Yacht",
373+
"uuid": "6f22fe65-7d7e-440f-b2a1-89dc592aac36",
374+
"practices": [],
375+
"prerequisites": [],
376+
"difficulty": 5
377+
},
378+
{
379+
"slug": "robot-simulator",
380+
"name": "Robot Simulator",
381+
"uuid": "af31c3d6-95e2-4817-aaea-4bac4e71e647",
382+
"practices": [],
383+
"prerequisites": [],
384+
"difficulty": 5
385+
},
370386
{
371387
"slug": "affine-cipher",
372388
"name": "Affine Cipher",
@@ -415,22 +431,6 @@
415431
"prerequisites": [],
416432
"difficulty": 6
417433
},
418-
{
419-
"slug": "robot-simulator",
420-
"name": "Robot Simulator",
421-
"uuid": "af31c3d6-95e2-4817-aaea-4bac4e71e647",
422-
"practices": [],
423-
"prerequisites": [],
424-
"difficulty": 5
425-
},
426-
{
427-
"slug": "circular-buffer",
428-
"name": "Circular Buffer",
429-
"uuid": "db61cc68-40d8-47a7-838e-508784153a10",
430-
"practices": [],
431-
"prerequisites": [],
432-
"difficulty": 8
433-
},
434434
{
435435
"slug": "queen-attack",
436436
"name": "Queen Attack",
@@ -463,6 +463,22 @@
463463
"prerequisites": [],
464464
"difficulty": 7
465465
},
466+
{
467+
"slug": "complex-numbers",
468+
"name": "Complex Numbers",
469+
"uuid": "5591f4e1-6f72-415e-a789-12eebd712f9a",
470+
"practices": [],
471+
"prerequisites": [],
472+
"difficulty": 8
473+
},
474+
{
475+
"slug": "circular-buffer",
476+
"name": "Circular Buffer",
477+
"uuid": "db61cc68-40d8-47a7-838e-508784153a10",
478+
"practices": [],
479+
"prerequisites": [],
480+
"difficulty": 8
481+
},
466482
{
467483
"slug": "knapsack",
468484
"name": "Knapsack",
@@ -502,14 +518,6 @@
502518
"practices": [],
503519
"prerequisites": [],
504520
"difficulty": 8
505-
},
506-
{
507-
"slug": "clock",
508-
"name": "Clock",
509-
"uuid": "a8a3657a-b490-4af8-be28-ac5df2c3f43b",
510-
"practices": [],
511-
"prerequisites": [],
512-
"difficulty": 2
513521
}
514522
]
515523
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Instructions
2+
3+
Given five dice and a category, calculate the score of the dice for that category.
4+
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+
~~~~
10+
11+
## Scores in Yacht
12+
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 |
27+
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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Introduction
2+
3+
Each year, something new is "all the rage" in your high school.
4+
This year it is a dice game: [Yacht][yacht].
5+
6+
The game of Yacht is from the same family as Poker Dice, Generala and particularly Yahtzee, of which it is a precursor.
7+
The game consists of twelve rounds.
8+
In each, five dice are rolled and the player chooses one of twelve categories.
9+
The chosen category is then used to score the throw of the dice.
10+
11+
[yacht]: https://en.wikipedia.org/wiki/Yacht_(dice_game)

exercises/practice/yacht/.eslintrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"root": true,
3+
"extends": "@exercism/eslint-config-javascript",
4+
"env": {
5+
"jest": true
6+
},
7+
"overrides": [
8+
{
9+
"files": ["*.spec.js"],
10+
"excludedFiles": ["custom.spec.js"],
11+
"extends": "@exercism/eslint-config-javascript/maintainers"
12+
}
13+
]
14+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"authors": [
3+
"atk"
4+
],
5+
"files": {
6+
"solution": [
7+
"yacht.wat"
8+
],
9+
"test": [
10+
"yacht.spec.js"
11+
],
12+
"example": [
13+
".meta/proof.ci.wat"
14+
],
15+
"invalidator": [
16+
"package.json"
17+
]
18+
},
19+
"blurb": "Score a single throw of dice in the game Yacht.",
20+
"source": "James Kilfiger, using Wikipedia",
21+
"source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)",
22+
"custom": {
23+
"version.tests.compatibility": "jest-27",
24+
"flag.tests.task-per-describe": false,
25+
"flag.tests.may-run-long": false,
26+
"flag.tests.includes-optional": false
27+
}
28+
}

0 commit comments

Comments
 (0)