From 226d0559304fc65032dd9bd3f5ed8ab1a2c019b9 Mon Sep 17 00:00:00 2001 From: habere-et-dispertire Date: Wed, 2 Aug 2023 00:00:14 +0100 Subject: [PATCH 1/5] [yacht] Implementation --- config.json | 9 + .../practice/yacht/.docs/instructions.md | 35 +++ exercises/practice/yacht/.meta/config.json | 19 ++ .../yacht/.meta/solutions/Yacht.rakumod | 19 ++ .../yacht/.meta/solutions/yacht.rakutest | 1 + .../practice/yacht/.meta/template-data.yaml | 36 +++ exercises/practice/yacht/.meta/tests.toml | 97 ++++++++ exercises/practice/yacht/Yacht.rakumod | 4 + exercises/practice/yacht/yacht.rakutest | 209 ++++++++++++++++++ 9 files changed, 429 insertions(+) create mode 100644 exercises/practice/yacht/.docs/instructions.md create mode 100644 exercises/practice/yacht/.meta/config.json create mode 100644 exercises/practice/yacht/.meta/solutions/Yacht.rakumod create mode 120000 exercises/practice/yacht/.meta/solutions/yacht.rakutest create mode 100644 exercises/practice/yacht/.meta/template-data.yaml create mode 100644 exercises/practice/yacht/.meta/tests.toml create mode 100644 exercises/practice/yacht/Yacht.rakumod create mode 100755 exercises/practice/yacht/yacht.rakutest diff --git a/config.json b/config.json index f0d93f46..68484b4d 100644 --- a/config.json +++ b/config.json @@ -634,6 +634,15 @@ "prerequisites": [], "difficulty": 1, "topics": [] + }, + { + "slug": "yacht", + "name": "Yacht", + "uuid": "5720dc50-7437-438a-903b-2bcd1b14f309", + "practices": [], + "prerequisites": [], + "difficulty": 1, + "topics": [] } ] }, diff --git a/exercises/practice/yacht/.docs/instructions.md b/exercises/practice/yacht/.docs/instructions.md new file mode 100644 index 00000000..163ba379 --- /dev/null +++ b/exercises/practice/yacht/.docs/instructions.md @@ -0,0 +1,35 @@ +# Instructions + +The dice game [Yacht][yacht] is from the same family as Poker Dice, Generala and particularly Yahtzee, of which it is a precursor. +In the game, five dice are rolled and the result can be entered in any of twelve categories. +The score of a throw of the dice depends on category chosen. + +## Scores in Yacht + +| Category | Score | Description | Example | +| -------- | ----- | ----------- | ------- | +| Ones | 1 × number of ones | Any combination | 1 1 1 4 5 scores 3 | +| Twos | 2 × number of twos | Any combination | 2 2 3 4 5 scores 4 | +| Threes | 3 × number of threes | Any combination | 3 3 3 3 3 scores 15 | +| Fours | 4 × number of fours | Any combination | 1 2 3 3 5 scores 0 | +| Fives | 5 × number of fives| Any combination | 5 1 5 2 5 scores 15 | +| Sixes | 6 × number of sixes | Any combination | 2 3 4 5 6 scores 6 | +| Full House | Total of the dice | Three of one number and two of another | 3 3 3 5 5 scores 19 | +| Four of a Kind | Total of the four dice | At least four dice showing the same face | 4 4 4 4 6 scores 16 | +| Little Straight | 30 points | 1-2-3-4-5 | 1 2 3 4 5 scores 30 | +| Big Straight | 30 points | 2-3-4-5-6 | 2 3 4 5 6 scores 30 | +| Choice | Sum of the dice | Any combination | 2 3 3 4 6 scores 18 | +| Yacht | 50 points | All five dice showing the same face | 4 4 4 4 4 scores 50 | + +If the dice do not satisfy the requirements of a category, the score is zero. +If, for example, *Four Of A Kind* is entered in the *Yacht* category, zero points are scored. +A *Yacht* scores zero if entered in the *Full House* category. + +## Task + +Given a list of values for five dice and a category, your solution should return the score of the dice for that category. +If the dice do not satisfy the requirements of the category your solution should return 0. +You can assume that five values will always be presented, and the value of each will be between one and six inclusively. +You should not assume that the dice are ordered. + +[yacht]: https://en.wikipedia.org/wiki/Yacht_(dice_game) diff --git a/exercises/practice/yacht/.meta/config.json b/exercises/practice/yacht/.meta/config.json new file mode 100644 index 00000000..2843fa2b --- /dev/null +++ b/exercises/practice/yacht/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "habere-et-dispertire" + ], + "files": { + "solution": [ + "Yacht.rakumod" + ], + "test": [ + "yacht.rakutest" + ], + "example": [ + ".meta/solutions/Yacht.rakumod" + ] + }, + "blurb": "Score a single throw of dice in the game Yacht.", + "source": "James Kilfiger, using wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)" +} diff --git a/exercises/practice/yacht/.meta/solutions/Yacht.rakumod b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod new file mode 100644 index 00000000..c0b03412 --- /dev/null +++ b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod @@ -0,0 +1,19 @@ +unit module Yacht; + +sub score ( @dice, $category ) is export { + given $category { + when 'choice' { return @dice.sum } + when 'ones' { return @dice.grep( 1 ).sum } + when 'twos' { return @dice.grep( 2 ).sum } + when 'threes' { return @dice.grep( 3 ).sum } + when 'fours' { return @dice.grep( 4 ).sum } + when 'fives' { return @dice.grep( 5 ).sum } + when 'sixes' { return @dice.grep( 6 ).sum } + when 'full house' { return @dice.Bag.values.sort ~~ ( 2,3 ) ?? @dice.sum !! 0 } + when 'four of a kind' { return @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } + when 'little straight' { return @dice.Bag ~~ (1,2,3,4,5).Bag ?? 30 !! 0 } + when 'big straight' { return @dice.Bag ~~ (2,3,4,5,6).Bag ?? 30 !! 0 } + when 'yacht' { return ( [==] @dice ) ?? 50 !! 0 } + default { return 0 } + } +} diff --git a/exercises/practice/yacht/.meta/solutions/yacht.rakutest b/exercises/practice/yacht/.meta/solutions/yacht.rakutest new file mode 120000 index 00000000..b75f8d9a --- /dev/null +++ b/exercises/practice/yacht/.meta/solutions/yacht.rakutest @@ -0,0 +1 @@ +../../yacht.rakutest \ No newline at end of file diff --git a/exercises/practice/yacht/.meta/template-data.yaml b/exercises/practice/yacht/.meta/template-data.yaml new file mode 100644 index 00000000..1f6a934c --- /dev/null +++ b/exercises/practice/yacht/.meta/template-data.yaml @@ -0,0 +1,36 @@ +unit: module + +properties: + score: + test: |- + sprintf(q:to/END/, (%case.List, %case, %case, %case).map(*.raku)); + cmp-ok( + score(%s, %s), + "==", + %s, + %s, + ); + END + +example: |- + sub score ( @dice, $category ) is export { + given $category { + when 'choice' { return @dice.sum } + when 'ones' { return @dice.grep( 1 ).sum } + when 'twos' { return @dice.grep( 2 ).sum } + when 'threes' { return @dice.grep( 3 ).sum } + when 'fours' { return @dice.grep( 4 ).sum } + when 'fives' { return @dice.grep( 5 ).sum } + when 'sixes' { return @dice.grep( 6 ).sum } + when 'full house' { return @dice.Bag.values.sort ~~ ( 2,3 ) ?? @dice.sum !! 0 } + when 'four of a kind' { return @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } + when 'little straight' { return @dice.Bag ~~ (1,2,3,4,5).Bag ?? 30 !! 0 } + when 'big straight' { return @dice.Bag ~~ (2,3,4,5,6).Bag ?? 30 !! 0 } + when 'yacht' { return ( [==] @dice ) ?? 50 !! 0 } + default { return 0 } + } + } + +stub: |- + sub score ( @dice, $category ) is export { + } diff --git a/exercises/practice/yacht/.meta/tests.toml b/exercises/practice/yacht/.meta/tests.toml new file mode 100644 index 00000000..b9d92037 --- /dev/null +++ b/exercises/practice/yacht/.meta/tests.toml @@ -0,0 +1,97 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[3060e4a5-4063-4deb-a380-a630b43a84b6] +description = "Yacht" + +[15026df2-f567-482f-b4d5-5297d57769d9] +description = "Not Yacht" + +[36b6af0c-ca06-4666-97de-5d31213957a4] +description = "Ones" + +[023a07c8-6c6e-44d0-bc17-efc5e1b8205a] +description = "Ones, out of order" + +[7189afac-cccd-4a74-8182-1cb1f374e496] +description = "No ones" + +[793c4292-dd14-49c4-9707-6d9c56cee725] +description = "Twos" + +[dc41bceb-d0c5-4634-a734-c01b4233a0c6] +description = "Fours" + +[f6125417-5c8a-4bca-bc5b-b4b76d0d28c8] +description = "Yacht counted as threes" + +[464fc809-96ed-46e4-acb8-d44e302e9726] +description = "Yacht of 3s counted as fives" + +[d054227f-3a71-4565-a684-5c7e621ec1e9] +description = "Fives" + +[e8a036e0-9d21-443a-8b5f-e15a9e19a761] +description = "Sixes" + +[51cb26db-6b24-49af-a9ff-12f53b252eea] +description = "Full house two small, three big" + +[1822ca9d-f235-4447-b430-2e8cfc448f0c] +description = "Full house three small, two big" + +[b208a3fc-db2e-4363-a936-9e9a71e69c07] +description = "Two pair is not a full house" + +[b90209c3-5956-445b-8a0b-0ac8b906b1c2] +description = "Four of a kind is not a full house" + +[32a3f4ee-9142-4edf-ba70-6c0f96eb4b0c] +description = "Yacht is not a full house" + +[b286084d-0568-4460-844a-ba79d71d79c6] +description = "Four of a Kind" + +[f25c0c90-5397-4732-9779-b1e9b5f612ca] +description = "Yacht can be scored as Four of a Kind" + +[9f8ef4f0-72bb-401a-a871-cbad39c9cb08] +description = "Full house is not Four of a Kind" + +[b4743c82-1eb8-4a65-98f7-33ad126905cd] +description = "Little Straight" + +[7ac08422-41bf-459c-8187-a38a12d080bc] +description = "Little Straight as Big Straight" + +[97bde8f7-9058-43ea-9de7-0bc3ed6d3002] +description = "Four in order but not a little straight" + +[cef35ff9-9c5e-4fd2-ae95-6e4af5e95a99] +description = "No pairs but not a little straight" + +[fd785ad2-c060-4e45-81c6-ea2bbb781b9d] +description = "Minimum is 1, maximum is 5, but not a little straight" + +[35bd74a6-5cf6-431a-97a3-4f713663f467] +description = "Big Straight" + +[87c67e1e-3e87-4f3a-a9b1-62927822b250] +description = "Big Straight as little straight" + +[c1fa0a3a-40ba-4153-a42d-32bc34d2521e] +description = "No pairs but not a big straight" + +[207e7300-5d10-43e5-afdd-213e3ac8827d] +description = "Choice" + +[b524c0cf-32d2-4b40-8fb3-be3500f3f135] +description = "Yacht as choice" diff --git a/exercises/practice/yacht/Yacht.rakumod b/exercises/practice/yacht/Yacht.rakumod new file mode 100644 index 00000000..e9f37aa0 --- /dev/null +++ b/exercises/practice/yacht/Yacht.rakumod @@ -0,0 +1,4 @@ +unit module Yacht; + +sub score ( @dice, $category ) is export { +} diff --git a/exercises/practice/yacht/yacht.rakutest b/exercises/practice/yacht/yacht.rakutest new file mode 100755 index 00000000..fd96f0a6 --- /dev/null +++ b/exercises/practice/yacht/yacht.rakutest @@ -0,0 +1,209 @@ +#!/usr/bin/env raku +use Test; +use lib $?FILE.IO.dirname; +use Yacht; + +cmp-ok( # begin: 3060e4a5-4063-4deb-a380-a630b43a84b6 + score((5, 5, 5, 5, 5), "yacht"), + "==", + 50, + "Yacht", +); # end: 3060e4a5-4063-4deb-a380-a630b43a84b6 + +cmp-ok( # begin: 15026df2-f567-482f-b4d5-5297d57769d9 + score((1, 3, 3, 2, 5), "yacht"), + "==", + 0, + "Not Yacht", +); # end: 15026df2-f567-482f-b4d5-5297d57769d9 + +cmp-ok( # begin: 36b6af0c-ca06-4666-97de-5d31213957a4 + score((1, 1, 1, 3, 5), "ones"), + "==", + 3, + "Ones", +); # end: 36b6af0c-ca06-4666-97de-5d31213957a4 + +cmp-ok( # begin: 023a07c8-6c6e-44d0-bc17-efc5e1b8205a + score((3, 1, 1, 5, 1), "ones"), + "==", + 3, + "Ones, out of order", +); # end: 023a07c8-6c6e-44d0-bc17-efc5e1b8205a + +cmp-ok( # begin: 7189afac-cccd-4a74-8182-1cb1f374e496 + score((4, 3, 6, 5, 5), "ones"), + "==", + 0, + "No ones", +); # end: 7189afac-cccd-4a74-8182-1cb1f374e496 + +cmp-ok( # begin: 793c4292-dd14-49c4-9707-6d9c56cee725 + score((2, 3, 4, 5, 6), "twos"), + "==", + 2, + "Twos", +); # end: 793c4292-dd14-49c4-9707-6d9c56cee725 + +cmp-ok( # begin: dc41bceb-d0c5-4634-a734-c01b4233a0c6 + score((1, 4, 1, 4, 1), "fours"), + "==", + 8, + "Fours", +); # end: dc41bceb-d0c5-4634-a734-c01b4233a0c6 + +cmp-ok( # begin: f6125417-5c8a-4bca-bc5b-b4b76d0d28c8 + score((3, 3, 3, 3, 3), "threes"), + "==", + 15, + "Yacht counted as threes", +); # end: f6125417-5c8a-4bca-bc5b-b4b76d0d28c8 + +cmp-ok( # begin: 464fc809-96ed-46e4-acb8-d44e302e9726 + score((3, 3, 3, 3, 3), "fives"), + "==", + 0, + "Yacht of 3s counted as fives", +); # end: 464fc809-96ed-46e4-acb8-d44e302e9726 + +cmp-ok( # begin: d054227f-3a71-4565-a684-5c7e621ec1e9 + score((1, 5, 3, 5, 3), "fives"), + "==", + 10, + "Fives", +); # end: d054227f-3a71-4565-a684-5c7e621ec1e9 + +cmp-ok( # begin: e8a036e0-9d21-443a-8b5f-e15a9e19a761 + score((2, 3, 4, 5, 6), "sixes"), + "==", + 6, + "Sixes", +); # end: e8a036e0-9d21-443a-8b5f-e15a9e19a761 + +cmp-ok( # begin: 51cb26db-6b24-49af-a9ff-12f53b252eea + score((2, 2, 4, 4, 4), "full house"), + "==", + 16, + "Full house two small, three big", +); # end: 51cb26db-6b24-49af-a9ff-12f53b252eea + +cmp-ok( # begin: 1822ca9d-f235-4447-b430-2e8cfc448f0c + score((5, 3, 3, 5, 3), "full house"), + "==", + 19, + "Full house three small, two big", +); # end: 1822ca9d-f235-4447-b430-2e8cfc448f0c + +cmp-ok( # begin: b208a3fc-db2e-4363-a936-9e9a71e69c07 + score((2, 2, 4, 4, 5), "full house"), + "==", + 0, + "Two pair is not a full house", +); # end: b208a3fc-db2e-4363-a936-9e9a71e69c07 + +cmp-ok( # begin: b90209c3-5956-445b-8a0b-0ac8b906b1c2 + score((1, 4, 4, 4, 4), "full house"), + "==", + 0, + "Four of a kind is not a full house", +); # end: b90209c3-5956-445b-8a0b-0ac8b906b1c2 + +cmp-ok( # begin: 32a3f4ee-9142-4edf-ba70-6c0f96eb4b0c + score((2, 2, 2, 2, 2), "full house"), + "==", + 0, + "Yacht is not a full house", +); # end: 32a3f4ee-9142-4edf-ba70-6c0f96eb4b0c + +cmp-ok( # begin: b286084d-0568-4460-844a-ba79d71d79c6 + score((6, 6, 4, 6, 6), "four of a kind"), + "==", + 24, + "Four of a Kind", +); # end: b286084d-0568-4460-844a-ba79d71d79c6 + +cmp-ok( # begin: f25c0c90-5397-4732-9779-b1e9b5f612ca + score((3, 3, 3, 3, 3), "four of a kind"), + "==", + 12, + "Yacht can be scored as Four of a Kind", +); # end: f25c0c90-5397-4732-9779-b1e9b5f612ca + +cmp-ok( # begin: 9f8ef4f0-72bb-401a-a871-cbad39c9cb08 + score((3, 3, 3, 5, 5), "four of a kind"), + "==", + 0, + "Full house is not Four of a Kind", +); # end: 9f8ef4f0-72bb-401a-a871-cbad39c9cb08 + +cmp-ok( # begin: b4743c82-1eb8-4a65-98f7-33ad126905cd + score((3, 5, 4, 1, 2), "little straight"), + "==", + 30, + "Little Straight", +); # end: b4743c82-1eb8-4a65-98f7-33ad126905cd + +cmp-ok( # begin: 7ac08422-41bf-459c-8187-a38a12d080bc + score((1, 2, 3, 4, 5), "big straight"), + "==", + 0, + "Little Straight as Big Straight", +); # end: 7ac08422-41bf-459c-8187-a38a12d080bc + +cmp-ok( # begin: 97bde8f7-9058-43ea-9de7-0bc3ed6d3002 + score((1, 1, 2, 3, 4), "little straight"), + "==", + 0, + "Four in order but not a little straight", +); # end: 97bde8f7-9058-43ea-9de7-0bc3ed6d3002 + +cmp-ok( # begin: cef35ff9-9c5e-4fd2-ae95-6e4af5e95a99 + score((1, 2, 3, 4, 6), "little straight"), + "==", + 0, + "No pairs but not a little straight", +); # end: cef35ff9-9c5e-4fd2-ae95-6e4af5e95a99 + +cmp-ok( # begin: fd785ad2-c060-4e45-81c6-ea2bbb781b9d + score((1, 1, 3, 4, 5), "little straight"), + "==", + 0, + "Minimum is 1, maximum is 5, but not a little straight", +); # end: fd785ad2-c060-4e45-81c6-ea2bbb781b9d + +cmp-ok( # begin: 35bd74a6-5cf6-431a-97a3-4f713663f467 + score((4, 6, 2, 5, 3), "big straight"), + "==", + 30, + "Big Straight", +); # end: 35bd74a6-5cf6-431a-97a3-4f713663f467 + +cmp-ok( # begin: 87c67e1e-3e87-4f3a-a9b1-62927822b250 + score((6, 5, 4, 3, 2), "little straight"), + "==", + 0, + "Big Straight as little straight", +); # end: 87c67e1e-3e87-4f3a-a9b1-62927822b250 + +cmp-ok( # begin: c1fa0a3a-40ba-4153-a42d-32bc34d2521e + score((6, 5, 4, 3, 1), "big straight"), + "==", + 0, + "No pairs but not a big straight", +); # end: c1fa0a3a-40ba-4153-a42d-32bc34d2521e + +cmp-ok( # begin: 207e7300-5d10-43e5-afdd-213e3ac8827d + score((3, 3, 5, 6, 6), "choice"), + "==", + 23, + "Choice", +); # end: 207e7300-5d10-43e5-afdd-213e3ac8827d + +cmp-ok( # begin: b524c0cf-32d2-4b40-8fb3-be3500f3f135 + score((2, 2, 2, 2, 2), "choice"), + "==", + 10, + "Yacht as choice", +); # end: b524c0cf-32d2-4b40-8fb3-be3500f3f135 + +done-testing; From 60c9dc8c5fb765a39ea4c154e76ce678bda9d6e9 Mon Sep 17 00:00:00 2001 From: habere-et-dispertire Date: Wed, 2 Aug 2023 09:57:20 +0100 Subject: [PATCH 2/5] Remove explicit return, add set logic to full house --- .../yacht/.meta/solutions/Yacht.rakumod | 28 +++++++++---------- .../practice/yacht/.meta/template-data.yaml | 28 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/exercises/practice/yacht/.meta/solutions/Yacht.rakumod b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod index c0b03412..e289b8e9 100644 --- a/exercises/practice/yacht/.meta/solutions/Yacht.rakumod +++ b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod @@ -1,19 +1,19 @@ unit module Yacht; -sub score ( @dice, $category ) is export { +sub score ( @dice, $category --> Int ) is export { given $category { - when 'choice' { return @dice.sum } - when 'ones' { return @dice.grep( 1 ).sum } - when 'twos' { return @dice.grep( 2 ).sum } - when 'threes' { return @dice.grep( 3 ).sum } - when 'fours' { return @dice.grep( 4 ).sum } - when 'fives' { return @dice.grep( 5 ).sum } - when 'sixes' { return @dice.grep( 6 ).sum } - when 'full house' { return @dice.Bag.values.sort ~~ ( 2,3 ) ?? @dice.sum !! 0 } - when 'four of a kind' { return @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } - when 'little straight' { return @dice.Bag ~~ (1,2,3,4,5).Bag ?? 30 !! 0 } - when 'big straight' { return @dice.Bag ~~ (2,3,4,5,6).Bag ?? 30 !! 0 } - when 'yacht' { return ( [==] @dice ) ?? 50 !! 0 } - default { return 0 } + when 'choice' { @dice.sum } + when 'ones' { @dice.grep( 1 ).sum } + when 'twos' { @dice.grep( 2 ).sum } + when 'threes' { @dice.grep( 3 ).sum } + when 'fours' { @dice.grep( 4 ).sum } + when 'fives' { @dice.grep( 5 ).sum } + when 'sixes' { @dice.grep( 6 ).sum } + when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } + when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } + when 'little straight' { @dice.Bag ~~ (1,2,3,4,5).Bag ?? 30 !! 0 } + when 'big straight' { @dice.Bag ~~ (2,3,4,5,6).Bag ?? 30 !! 0 } + when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } + default { 0 } } } diff --git a/exercises/practice/yacht/.meta/template-data.yaml b/exercises/practice/yacht/.meta/template-data.yaml index 1f6a934c..2f8d94fa 100644 --- a/exercises/practice/yacht/.meta/template-data.yaml +++ b/exercises/practice/yacht/.meta/template-data.yaml @@ -13,21 +13,21 @@ properties: END example: |- - sub score ( @dice, $category ) is export { + sub score ( @dice, $category --> Int ) is export { given $category { - when 'choice' { return @dice.sum } - when 'ones' { return @dice.grep( 1 ).sum } - when 'twos' { return @dice.grep( 2 ).sum } - when 'threes' { return @dice.grep( 3 ).sum } - when 'fours' { return @dice.grep( 4 ).sum } - when 'fives' { return @dice.grep( 5 ).sum } - when 'sixes' { return @dice.grep( 6 ).sum } - when 'full house' { return @dice.Bag.values.sort ~~ ( 2,3 ) ?? @dice.sum !! 0 } - when 'four of a kind' { return @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } - when 'little straight' { return @dice.Bag ~~ (1,2,3,4,5).Bag ?? 30 !! 0 } - when 'big straight' { return @dice.Bag ~~ (2,3,4,5,6).Bag ?? 30 !! 0 } - when 'yacht' { return ( [==] @dice ) ?? 50 !! 0 } - default { return 0 } + when 'choice' { @dice.sum } + when 'ones' { @dice.grep( 1 ).sum } + when 'twos' { @dice.grep( 2 ).sum } + when 'threes' { @dice.grep( 3 ).sum } + when 'fours' { @dice.grep( 4 ).sum } + when 'fives' { @dice.grep( 5 ).sum } + when 'sixes' { @dice.grep( 6 ).sum } + when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } + when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } + when 'little straight' { @dice.Bag ~~ (1,2,3,4,5).Bag ?? 30 !! 0 } + when 'big straight' { @dice.Bag ~~ (2,3,4,5,6).Bag ?? 30 !! 0 } + when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } + default { 0 } } } From 00b6d13154ff21fd113c09037c31d09dd284266a Mon Sep 17 00:00:00 2001 From: habere-et-dispertire Date: Wed, 2 Aug 2023 16:49:49 +0100 Subject: [PATCH 3/5] whitespace reformatting --- exercises/practice/yacht/.meta/solutions/Yacht.rakumod | 10 +++++----- exercises/practice/yacht/.meta/template-data.yaml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/exercises/practice/yacht/.meta/solutions/Yacht.rakumod b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod index e289b8e9..59e1f609 100644 --- a/exercises/practice/yacht/.meta/solutions/Yacht.rakumod +++ b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod @@ -9,11 +9,11 @@ sub score ( @dice, $category --> Int ) is export { when 'fours' { @dice.grep( 4 ).sum } when 'fives' { @dice.grep( 5 ).sum } when 'sixes' { @dice.grep( 6 ).sum } - when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } + when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } + when 'little straight' { @dice.Bag ~~ ( 1, 2, 3, 4, 5 ).Bag ?? 30 !! 0 } + when 'big straight' { @dice.Bag ~~ ( 2, 3, 4, 5, 6 ).Bag ?? 30 !! 0 } when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } - when 'little straight' { @dice.Bag ~~ (1,2,3,4,5).Bag ?? 30 !! 0 } - when 'big straight' { @dice.Bag ~~ (2,3,4,5,6).Bag ?? 30 !! 0 } - when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } - default { 0 } + when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } + default { 0 } } } diff --git a/exercises/practice/yacht/.meta/template-data.yaml b/exercises/practice/yacht/.meta/template-data.yaml index 2f8d94fa..1dc16ec6 100644 --- a/exercises/practice/yacht/.meta/template-data.yaml +++ b/exercises/practice/yacht/.meta/template-data.yaml @@ -22,12 +22,12 @@ example: |- when 'fours' { @dice.grep( 4 ).sum } when 'fives' { @dice.grep( 5 ).sum } when 'sixes' { @dice.grep( 6 ).sum } - when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } + when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } + when 'little straight' { @dice.Bag ~~ ( 1, 2, 3, 4, 5 ).Bag ?? 30 !! 0 } + when 'big straight' { @dice.Bag ~~ ( 2, 3, 4, 5, 6 ).Bag ?? 30 !! 0 } when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } - when 'little straight' { @dice.Bag ~~ (1,2,3,4,5).Bag ?? 30 !! 0 } - when 'big straight' { @dice.Bag ~~ (2,3,4,5,6).Bag ?? 30 !! 0 } - when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } - default { 0 } + when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } + default { 0 } } } From 5d41add4aa2d3286a2ca1289860beba413a8cb3c Mon Sep 17 00:00:00 2001 From: habere-et-dispertire Date: Wed, 2 Aug 2023 20:11:59 +0100 Subject: [PATCH 4/5] Never nesting --- .../yacht/.meta/solutions/Yacht.rakumod | 29 +++++++++---------- .../practice/yacht/.meta/template-data.yaml | 29 +++++++++---------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/exercises/practice/yacht/.meta/solutions/Yacht.rakumod b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod index 59e1f609..199b0e62 100644 --- a/exercises/practice/yacht/.meta/solutions/Yacht.rakumod +++ b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod @@ -1,19 +1,16 @@ unit module Yacht; -sub score ( @dice, $category --> Int ) is export { - given $category { - when 'choice' { @dice.sum } - when 'ones' { @dice.grep( 1 ).sum } - when 'twos' { @dice.grep( 2 ).sum } - when 'threes' { @dice.grep( 3 ).sum } - when 'fours' { @dice.grep( 4 ).sum } - when 'fives' { @dice.grep( 5 ).sum } - when 'sixes' { @dice.grep( 6 ).sum } - when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } - when 'little straight' { @dice.Bag ~~ ( 1, 2, 3, 4, 5 ).Bag ?? 30 !! 0 } - when 'big straight' { @dice.Bag ~~ ( 2, 3, 4, 5, 6 ).Bag ?? 30 !! 0 } - when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } - when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } - default { 0 } - } +sub score ( @dice, $_ --> Int ) is export { + when 'choice' { @dice.sum } + when 'ones' { @dice.grep( 1 ).sum } + when 'twos' { @dice.grep( 2 ).sum } + when 'threes' { @dice.grep( 3 ).sum } + when 'fours' { @dice.grep( 4 ).sum } + when 'fives' { @dice.grep( 5 ).sum } + when 'sixes' { @dice.grep( 6 ).sum } + when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } + when 'little straight' { @dice.Bag ~~ ( 1..5 ).Bag ?? 30 !! 0 } + when 'big straight' { @dice.Bag ~~ ( 2..6 ).Bag ?? 30 !! 0 } + when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } + when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } } diff --git a/exercises/practice/yacht/.meta/template-data.yaml b/exercises/practice/yacht/.meta/template-data.yaml index 1dc16ec6..0a367aaf 100644 --- a/exercises/practice/yacht/.meta/template-data.yaml +++ b/exercises/practice/yacht/.meta/template-data.yaml @@ -13,22 +13,19 @@ properties: END example: |- - sub score ( @dice, $category --> Int ) is export { - given $category { - when 'choice' { @dice.sum } - when 'ones' { @dice.grep( 1 ).sum } - when 'twos' { @dice.grep( 2 ).sum } - when 'threes' { @dice.grep( 3 ).sum } - when 'fours' { @dice.grep( 4 ).sum } - when 'fives' { @dice.grep( 5 ).sum } - when 'sixes' { @dice.grep( 6 ).sum } - when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } - when 'little straight' { @dice.Bag ~~ ( 1, 2, 3, 4, 5 ).Bag ?? 30 !! 0 } - when 'big straight' { @dice.Bag ~~ ( 2, 3, 4, 5, 6 ).Bag ?? 30 !! 0 } - when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } - when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } - default { 0 } - } + sub score ( @dice, $_ --> Int ) is export { + when 'choice' { @dice.sum } + when 'ones' { @dice.grep( 1 ).sum } + when 'twos' { @dice.grep( 2 ).sum } + when 'threes' { @dice.grep( 3 ).sum } + when 'fours' { @dice.grep( 4 ).sum } + when 'fives' { @dice.grep( 5 ).sum } + when 'sixes' { @dice.grep( 6 ).sum } + when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } + when 'little straight' { @dice.Bag ~~ ( 1..5 ).Bag ?? 30 !! 0 } + when 'big straight' { @dice.Bag ~~ ( 2..6 ).Bag ?? 30 !! 0 } + when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } + when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } } stub: |- From a16acf210a8ce33d95c154e64d3538f95dbfed6b Mon Sep 17 00:00:00 2001 From: Daniel Mita Date: Wed, 2 Aug 2023 20:31:06 +0100 Subject: [PATCH 5/5] Use pair as sub option --- exercises/practice/yacht/.meta/config.json | 3 + .../yacht/.meta/solutions/Yacht.rakumod | 33 ++++++----- .../practice/yacht/.meta/template-data.yaml | 39 ++++++++----- exercises/practice/yacht/Yacht.rakumod | 2 +- exercises/practice/yacht/yacht.rakutest | 58 +++++++++---------- 5 files changed, 76 insertions(+), 59 deletions(-) diff --git a/exercises/practice/yacht/.meta/config.json b/exercises/practice/yacht/.meta/config.json index 2843fa2b..f032e2cc 100644 --- a/exercises/practice/yacht/.meta/config.json +++ b/exercises/practice/yacht/.meta/config.json @@ -2,6 +2,9 @@ "authors": [ "habere-et-dispertire" ], + "contributors": [ + "m-dango" + ], "files": { "solution": [ "Yacht.rakumod" diff --git a/exercises/practice/yacht/.meta/solutions/Yacht.rakumod b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod index 199b0e62..e6653c44 100644 --- a/exercises/practice/yacht/.meta/solutions/Yacht.rakumod +++ b/exercises/practice/yacht/.meta/solutions/Yacht.rakumod @@ -1,16 +1,23 @@ unit module Yacht; -sub score ( @dice, $_ --> Int ) is export { - when 'choice' { @dice.sum } - when 'ones' { @dice.grep( 1 ).sum } - when 'twos' { @dice.grep( 2 ).sum } - when 'threes' { @dice.grep( 3 ).sum } - when 'fours' { @dice.grep( 4 ).sum } - when 'fives' { @dice.grep( 5 ).sum } - when 'sixes' { @dice.grep( 6 ).sum } - when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } - when 'little straight' { @dice.Bag ~~ ( 1..5 ).Bag ?? 30 !! 0 } - when 'big straight' { @dice.Bag ~~ ( 2..6 ).Bag ?? 30 !! 0 } - when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } - when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } +sub score ( $dice, *%category --> Int ) is export { + given %category { + when *. { $dice.kxxv.sum } + + when *. { $dice{1} } + when *. { $dice{2} * 2 } + when *. { $dice{3} * 3 } + when *. { $dice{4} * 4 } + when *. { $dice{5} * 5 } + when *. { $dice{6} * 6 } + + when *. { $dice.keys == 1 ?? 50 !! 0 } + when *. { $dice (==) ( 1 .. 5 ).Bag ?? 30 !! 0 } + when *. { $dice (==) ( 2 .. 6 ).Bag ?? 30 !! 0 } + + when *. { with $dice.first( *.value >= 4 ) { .key * 4 } else { 0 } } + when *. { $dice.values (==) ( 2, 3 ) ?? $dice.kxxv.sum !! 0 } + + default { 0 } + } } diff --git a/exercises/practice/yacht/.meta/template-data.yaml b/exercises/practice/yacht/.meta/template-data.yaml index 0a367aaf..1e7e5cbe 100644 --- a/exercises/practice/yacht/.meta/template-data.yaml +++ b/exercises/practice/yacht/.meta/template-data.yaml @@ -3,9 +3,9 @@ unit: module properties: score: test: |- - sprintf(q:to/END/, (%case.List, %case, %case, %case).map(*.raku)); + sprintf(q:to/END/, %case.List.raku, %case.subst(/' '/, '-', :g), %case, %case.raku); cmp-ok( - score(%s, %s), + score( %s.Bag, :%s ), "==", %s, %s, @@ -13,21 +13,28 @@ properties: END example: |- - sub score ( @dice, $_ --> Int ) is export { - when 'choice' { @dice.sum } - when 'ones' { @dice.grep( 1 ).sum } - when 'twos' { @dice.grep( 2 ).sum } - when 'threes' { @dice.grep( 3 ).sum } - when 'fours' { @dice.grep( 4 ).sum } - when 'fives' { @dice.grep( 5 ).sum } - when 'sixes' { @dice.grep( 6 ).sum } - when 'yacht' { ( [==] @dice ) ?? 50 !! 0 } - when 'little straight' { @dice.Bag ~~ ( 1..5 ).Bag ?? 30 !! 0 } - when 'big straight' { @dice.Bag ~~ ( 2..6 ).Bag ?? 30 !! 0 } - when 'four of a kind' { @dice.Bag.first( *.value >= 4 ).key * 4 // 0 } - when 'full house' { @dice.Bag.values (==) ( 2, 3 ) ?? @dice.sum !! 0 } + sub score ( $dice, *%category --> Int ) is export { + given %category { + when *. { $dice.kxxv.sum } + + when *. { $dice{1} } + when *. { $dice{2} * 2 } + when *. { $dice{3} * 3 } + when *. { $dice{4} * 4 } + when *. { $dice{5} * 5 } + when *. { $dice{6} * 6 } + + when *. { $dice.keys == 1 ?? 50 !! 0 } + when *. { $dice (==) ( 1 .. 5 ).Bag ?? 30 !! 0 } + when *. { $dice (==) ( 2 .. 6 ).Bag ?? 30 !! 0 } + + when *. { with $dice.first( *.value >= 4 ) { .key * 4 } else { 0 } } + when *. { $dice.values (==) ( 2, 3 ) ?? $dice.kxxv.sum !! 0 } + + default { 0 } + } } stub: |- - sub score ( @dice, $category ) is export { + sub score ( $dice, *%category ) is export { } diff --git a/exercises/practice/yacht/Yacht.rakumod b/exercises/practice/yacht/Yacht.rakumod index e9f37aa0..0735530c 100644 --- a/exercises/practice/yacht/Yacht.rakumod +++ b/exercises/practice/yacht/Yacht.rakumod @@ -1,4 +1,4 @@ unit module Yacht; -sub score ( @dice, $category ) is export { +sub score ( $dice, *%category ) is export { } diff --git a/exercises/practice/yacht/yacht.rakutest b/exercises/practice/yacht/yacht.rakutest index fd96f0a6..f0d87e0e 100755 --- a/exercises/practice/yacht/yacht.rakutest +++ b/exercises/practice/yacht/yacht.rakutest @@ -4,203 +4,203 @@ use lib $?FILE.IO.dirname; use Yacht; cmp-ok( # begin: 3060e4a5-4063-4deb-a380-a630b43a84b6 - score((5, 5, 5, 5, 5), "yacht"), + score( (5, 5, 5, 5, 5).Bag, :yacht ), "==", 50, "Yacht", ); # end: 3060e4a5-4063-4deb-a380-a630b43a84b6 cmp-ok( # begin: 15026df2-f567-482f-b4d5-5297d57769d9 - score((1, 3, 3, 2, 5), "yacht"), + score( (1, 3, 3, 2, 5).Bag, :yacht ), "==", 0, "Not Yacht", ); # end: 15026df2-f567-482f-b4d5-5297d57769d9 cmp-ok( # begin: 36b6af0c-ca06-4666-97de-5d31213957a4 - score((1, 1, 1, 3, 5), "ones"), + score( (1, 1, 1, 3, 5).Bag, :ones ), "==", 3, "Ones", ); # end: 36b6af0c-ca06-4666-97de-5d31213957a4 cmp-ok( # begin: 023a07c8-6c6e-44d0-bc17-efc5e1b8205a - score((3, 1, 1, 5, 1), "ones"), + score( (3, 1, 1, 5, 1).Bag, :ones ), "==", 3, "Ones, out of order", ); # end: 023a07c8-6c6e-44d0-bc17-efc5e1b8205a cmp-ok( # begin: 7189afac-cccd-4a74-8182-1cb1f374e496 - score((4, 3, 6, 5, 5), "ones"), + score( (4, 3, 6, 5, 5).Bag, :ones ), "==", 0, "No ones", ); # end: 7189afac-cccd-4a74-8182-1cb1f374e496 cmp-ok( # begin: 793c4292-dd14-49c4-9707-6d9c56cee725 - score((2, 3, 4, 5, 6), "twos"), + score( (2, 3, 4, 5, 6).Bag, :twos ), "==", 2, "Twos", ); # end: 793c4292-dd14-49c4-9707-6d9c56cee725 cmp-ok( # begin: dc41bceb-d0c5-4634-a734-c01b4233a0c6 - score((1, 4, 1, 4, 1), "fours"), + score( (1, 4, 1, 4, 1).Bag, :fours ), "==", 8, "Fours", ); # end: dc41bceb-d0c5-4634-a734-c01b4233a0c6 cmp-ok( # begin: f6125417-5c8a-4bca-bc5b-b4b76d0d28c8 - score((3, 3, 3, 3, 3), "threes"), + score( (3, 3, 3, 3, 3).Bag, :threes ), "==", 15, "Yacht counted as threes", ); # end: f6125417-5c8a-4bca-bc5b-b4b76d0d28c8 cmp-ok( # begin: 464fc809-96ed-46e4-acb8-d44e302e9726 - score((3, 3, 3, 3, 3), "fives"), + score( (3, 3, 3, 3, 3).Bag, :fives ), "==", 0, "Yacht of 3s counted as fives", ); # end: 464fc809-96ed-46e4-acb8-d44e302e9726 cmp-ok( # begin: d054227f-3a71-4565-a684-5c7e621ec1e9 - score((1, 5, 3, 5, 3), "fives"), + score( (1, 5, 3, 5, 3).Bag, :fives ), "==", 10, "Fives", ); # end: d054227f-3a71-4565-a684-5c7e621ec1e9 cmp-ok( # begin: e8a036e0-9d21-443a-8b5f-e15a9e19a761 - score((2, 3, 4, 5, 6), "sixes"), + score( (2, 3, 4, 5, 6).Bag, :sixes ), "==", 6, "Sixes", ); # end: e8a036e0-9d21-443a-8b5f-e15a9e19a761 cmp-ok( # begin: 51cb26db-6b24-49af-a9ff-12f53b252eea - score((2, 2, 4, 4, 4), "full house"), + score( (2, 2, 4, 4, 4).Bag, :full-house ), "==", 16, "Full house two small, three big", ); # end: 51cb26db-6b24-49af-a9ff-12f53b252eea cmp-ok( # begin: 1822ca9d-f235-4447-b430-2e8cfc448f0c - score((5, 3, 3, 5, 3), "full house"), + score( (5, 3, 3, 5, 3).Bag, :full-house ), "==", 19, "Full house three small, two big", ); # end: 1822ca9d-f235-4447-b430-2e8cfc448f0c cmp-ok( # begin: b208a3fc-db2e-4363-a936-9e9a71e69c07 - score((2, 2, 4, 4, 5), "full house"), + score( (2, 2, 4, 4, 5).Bag, :full-house ), "==", 0, "Two pair is not a full house", ); # end: b208a3fc-db2e-4363-a936-9e9a71e69c07 cmp-ok( # begin: b90209c3-5956-445b-8a0b-0ac8b906b1c2 - score((1, 4, 4, 4, 4), "full house"), + score( (1, 4, 4, 4, 4).Bag, :full-house ), "==", 0, "Four of a kind is not a full house", ); # end: b90209c3-5956-445b-8a0b-0ac8b906b1c2 cmp-ok( # begin: 32a3f4ee-9142-4edf-ba70-6c0f96eb4b0c - score((2, 2, 2, 2, 2), "full house"), + score( (2, 2, 2, 2, 2).Bag, :full-house ), "==", 0, "Yacht is not a full house", ); # end: 32a3f4ee-9142-4edf-ba70-6c0f96eb4b0c cmp-ok( # begin: b286084d-0568-4460-844a-ba79d71d79c6 - score((6, 6, 4, 6, 6), "four of a kind"), + score( (6, 6, 4, 6, 6).Bag, :four-of-a-kind ), "==", 24, "Four of a Kind", ); # end: b286084d-0568-4460-844a-ba79d71d79c6 cmp-ok( # begin: f25c0c90-5397-4732-9779-b1e9b5f612ca - score((3, 3, 3, 3, 3), "four of a kind"), + score( (3, 3, 3, 3, 3).Bag, :four-of-a-kind ), "==", 12, "Yacht can be scored as Four of a Kind", ); # end: f25c0c90-5397-4732-9779-b1e9b5f612ca cmp-ok( # begin: 9f8ef4f0-72bb-401a-a871-cbad39c9cb08 - score((3, 3, 3, 5, 5), "four of a kind"), + score( (3, 3, 3, 5, 5).Bag, :four-of-a-kind ), "==", 0, "Full house is not Four of a Kind", ); # end: 9f8ef4f0-72bb-401a-a871-cbad39c9cb08 cmp-ok( # begin: b4743c82-1eb8-4a65-98f7-33ad126905cd - score((3, 5, 4, 1, 2), "little straight"), + score( (3, 5, 4, 1, 2).Bag, :little-straight ), "==", 30, "Little Straight", ); # end: b4743c82-1eb8-4a65-98f7-33ad126905cd cmp-ok( # begin: 7ac08422-41bf-459c-8187-a38a12d080bc - score((1, 2, 3, 4, 5), "big straight"), + score( (1, 2, 3, 4, 5).Bag, :big-straight ), "==", 0, "Little Straight as Big Straight", ); # end: 7ac08422-41bf-459c-8187-a38a12d080bc cmp-ok( # begin: 97bde8f7-9058-43ea-9de7-0bc3ed6d3002 - score((1, 1, 2, 3, 4), "little straight"), + score( (1, 1, 2, 3, 4).Bag, :little-straight ), "==", 0, "Four in order but not a little straight", ); # end: 97bde8f7-9058-43ea-9de7-0bc3ed6d3002 cmp-ok( # begin: cef35ff9-9c5e-4fd2-ae95-6e4af5e95a99 - score((1, 2, 3, 4, 6), "little straight"), + score( (1, 2, 3, 4, 6).Bag, :little-straight ), "==", 0, "No pairs but not a little straight", ); # end: cef35ff9-9c5e-4fd2-ae95-6e4af5e95a99 cmp-ok( # begin: fd785ad2-c060-4e45-81c6-ea2bbb781b9d - score((1, 1, 3, 4, 5), "little straight"), + score( (1, 1, 3, 4, 5).Bag, :little-straight ), "==", 0, "Minimum is 1, maximum is 5, but not a little straight", ); # end: fd785ad2-c060-4e45-81c6-ea2bbb781b9d cmp-ok( # begin: 35bd74a6-5cf6-431a-97a3-4f713663f467 - score((4, 6, 2, 5, 3), "big straight"), + score( (4, 6, 2, 5, 3).Bag, :big-straight ), "==", 30, "Big Straight", ); # end: 35bd74a6-5cf6-431a-97a3-4f713663f467 cmp-ok( # begin: 87c67e1e-3e87-4f3a-a9b1-62927822b250 - score((6, 5, 4, 3, 2), "little straight"), + score( (6, 5, 4, 3, 2).Bag, :little-straight ), "==", 0, "Big Straight as little straight", ); # end: 87c67e1e-3e87-4f3a-a9b1-62927822b250 cmp-ok( # begin: c1fa0a3a-40ba-4153-a42d-32bc34d2521e - score((6, 5, 4, 3, 1), "big straight"), + score( (6, 5, 4, 3, 1).Bag, :big-straight ), "==", 0, "No pairs but not a big straight", ); # end: c1fa0a3a-40ba-4153-a42d-32bc34d2521e cmp-ok( # begin: 207e7300-5d10-43e5-afdd-213e3ac8827d - score((3, 3, 5, 6, 6), "choice"), + score( (3, 3, 5, 6, 6).Bag, :choice ), "==", 23, "Choice", ); # end: 207e7300-5d10-43e5-afdd-213e3ac8827d cmp-ok( # begin: b524c0cf-32d2-4b40-8fb3-be3500f3f135 - score((2, 2, 2, 2, 2), "choice"), + score( (2, 2, 2, 2, 2).Bag, :choice ), "==", 10, "Yacht as choice",