From 9899fe0302ed133eee419a9b093de8e6e98ba4fb Mon Sep 17 00:00:00 2001 From: habere-et-dispertire Date: Sat, 3 Jun 2023 19:32:46 +0100 Subject: [PATCH 1/3] [killer-sudoku-helper] Implementation --- config.json | 11 ++- .../.docs/instructions.md | 63 ++++++++++++ .../killer-sudoku-helper/.meta/config.json | 19 ++++ .../solutions/KillerSudokuHelper.rakumod | 5 + .../solutions/killer-sudoku-helper.rakutest | 1 + .../.meta/template-data.yaml | 21 ++++ .../killer-sudoku-helper/.meta/tests.toml | 49 ++++++++++ .../KillerSudokuHelper.rakumod | 4 + .../killer-sudoku-helper.rakutest | 97 +++++++++++++++++++ 9 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 exercises/practice/killer-sudoku-helper/.docs/instructions.md create mode 100644 exercises/practice/killer-sudoku-helper/.meta/config.json create mode 100644 exercises/practice/killer-sudoku-helper/.meta/solutions/KillerSudokuHelper.rakumod create mode 120000 exercises/practice/killer-sudoku-helper/.meta/solutions/killer-sudoku-helper.rakutest create mode 100644 exercises/practice/killer-sudoku-helper/.meta/template-data.yaml create mode 100644 exercises/practice/killer-sudoku-helper/.meta/tests.toml create mode 100644 exercises/practice/killer-sudoku-helper/KillerSudokuHelper.rakumod create mode 100755 exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest diff --git a/config.json b/config.json index ee605c1b..032cc774 100644 --- a/config.json +++ b/config.json @@ -481,7 +481,16 @@ "prerequisites": [], "difficulty": 1, "topics": [] - } + }, + { + "slug": "killer-sudoku-helper", + "name": "Killer Sudoku Helper", + "uuid": "f7071a4d-0341-41eb-a37b-92b3c8d10b08", + "practices": [], + "prerequisites": [], + "difficulty": 1, + "topics": [] + } ] }, "concepts": [], diff --git a/exercises/practice/killer-sudoku-helper/.docs/instructions.md b/exercises/practice/killer-sudoku-helper/.docs/instructions.md new file mode 100644 index 00000000..2347ab26 --- /dev/null +++ b/exercises/practice/killer-sudoku-helper/.docs/instructions.md @@ -0,0 +1,63 @@ +# Instructions + +A friend of yours is learning how to solve Killer Sudokus (rules below) but struggling to figure out which digits can go in a cage. +They ask you to help them out by writing a small program that lists all valid combinations for a given cage, and any constraints that affect the cage. + +To make the output of your program easy to read, the combinations it returns must be sorted. + +## Killer Sudoku Rules + +- [Standard Sudoku rules][sudoku-rules] apply. +- The digits in a cage, usually marked by a dotted line, add up to the small number given in the corner of the cage. +- A digit may only occur once in a cage. + +For a more detailed explanation, check out [this guide][killer-guide]. + +## Example 1: Cage with only 1 possible combination + +In a 3-digit cage with a sum of 7, there is only one valid combination: 124. + +- 1 + 2 + 4 = 7 +- Any other combination that adds up to 7, e.g. 232, would violate the rule of not repeating digits within a cage. + +![Sudoku grid, with three killer cages that are marked as grouped together. The first killer cage is in the 3×3 box in the top left corner of the grid. The middle column of that box forms the cage, with the followings cells from top to bottom: first cell contains a 1 and a pencil mark of 7, indicating a cage sum of 7, second cell contains a 2, third cell contains a 5. The numbers are highlighted in red to indicate a mistake. The second killer cage is in the central 3×3 box of the grid. The middle column of that box forms the cage, with the followings cells from top to bottom: first cell contains a 1 and a pencil mark of 7, indicating a cage sum of 7, second cell contains a 2, third cell contains a 4. None of the numbers in this cage are highlighted and therefore don't contain any mistakes. The third killer cage follows the outside corner of the central 3×3 box of the grid. It is made up of the following three cells: the top left cell of the cage contains a 2, highlighted in red, and a cage sum of 7. The top right cell of the cage contains a 3. The bottom right cell of the cage contains a 2, highlighted in red. All other cells are empty.][one-solution-img] + +## Example 2: Cage with several combinations + +In a 2-digit cage with a sum 10, there are 4 possible combinations: + +- 19 +- 28 +- 37 +- 46 + +![Sudoku grid, all squares empty except for the middle column, column 5, which has 8 rows filled. Each continguous two rows form a killer cage and are marked as grouped together. From top to bottom: first group is a cell with value 1 and a pencil mark indicating a cage sum of 10, cell with value 9. Second group is a cell with value 2 and a pencil mark of 10, cell with value 8. Third group is a cell with value 3 and a pencil mark of 10, cell with value 7. Fourth group is a cell with value 4 and a pencil mark of 10, cell with value 6. The last cell in the column is empty.][four-solutions-img] + +## Example 3: Cage with several combinations that is restricted + +In a 2-digit cage with a sum 10, where the column already contains a 1 and a 4, there are 2 possible combinations: + +- 28 +- 37 + +19 and 46 are not possible due to the 1 and 4 in the column according to standard Sudoku rules. + +![Sudoku grid, all squares empty except for the middle column, column 5, which has 8 rows filled. The first row contains a 4, the second is empty, and the third contains a 1. The 1 is highlighted in red to indicate a mistake. The last 6 rows in the column form killer cages of two cells each. From top to bottom: first group is a cell with value 2 and a pencil mark indicating a cage sum of 10, cell with value 8. Second group is a cell with value 3 and a pencil mark of 10, cell with value 7. Third group is a cell with value 1, highlighted in red, and a pencil mark of 10, cell with value 9.][not-possible-img] + +## Trying it yourself + +If you want to give an approachable Killer Sudoku a go, you can try out [this puzzle][clover-puzzle] by Clover, featured by [Mark Goodliffe on Cracking The Cryptic on the 21st of June 2021][goodliffe-video]. + +You can also find Killer Sudokus in varying difficulty in numerous newspapers, as well as Sudoku apps, books and websites. + +## Credit + +The screenshots above have been generated using [F-Puzzles.com](https://www.f-puzzles.com/), a Puzzle Setting Tool by Eric Fox. + +[sudoku-rules]: https://masteringsudoku.com/sudoku-rules-beginners/ +[killer-guide]: https://masteringsudoku.com/killer-sudoku/ +[one-solution-img]: https://exercism-v3-icons.s3.eu-west-2.amazonaws.com/images/exercises/killer-sudoku-helper/example1.png +[four-solutions-img]: https://exercism-v3-icons.s3.eu-west-2.amazonaws.com/images/exercises/killer-sudoku-helper/example2.png +[not-possible-img]: https://exercism-v3-icons.s3.eu-west-2.amazonaws.com/images/exercises/killer-sudoku-helper/example3.png +[clover-puzzle]: https://app.crackingthecryptic.com/sudoku/HqTBn3Pr6R +[goodliffe-video]: https://youtu.be/c_NjEbFEeW0?t=1180 diff --git a/exercises/practice/killer-sudoku-helper/.meta/config.json b/exercises/practice/killer-sudoku-helper/.meta/config.json new file mode 100644 index 00000000..7ae48de0 --- /dev/null +++ b/exercises/practice/killer-sudoku-helper/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "habere-et-dispertire" + ], + "files": { + "solution": [ + "KillerSudokuHelper.rakumod" + ], + "test": [ + "killer-sudoku-helper.rakutest" + ], + "example": [ + ".meta/solutions/KillerSudokuHelper.rakumod" + ] + }, + "blurb": "Write a tool that makes it easier to solve Killer Sudokus", + "source": "Created by Sascha Mann, Jeremy Walker, and BethanyG for the Julia track on Exercism.", + "source_url": "https://github.com/exercism/julia/pull/413" +} diff --git a/exercises/practice/killer-sudoku-helper/.meta/solutions/KillerSudokuHelper.rakumod b/exercises/practice/killer-sudoku-helper/.meta/solutions/KillerSudokuHelper.rakumod new file mode 100644 index 00000000..c704f503 --- /dev/null +++ b/exercises/practice/killer-sudoku-helper/.meta/solutions/KillerSudokuHelper.rakumod @@ -0,0 +1,5 @@ +unit module KillerSudokuHelper; + +sub killer-sudoku-helper ( :$sum, :$size, :$exclude ) is export { + ( 1..9 ).combinations( $size ).grep( *.sum == $sum ).grep( *.none (elem) $exclude ) +} diff --git a/exercises/practice/killer-sudoku-helper/.meta/solutions/killer-sudoku-helper.rakutest b/exercises/practice/killer-sudoku-helper/.meta/solutions/killer-sudoku-helper.rakutest new file mode 120000 index 00000000..9ad174bc --- /dev/null +++ b/exercises/practice/killer-sudoku-helper/.meta/solutions/killer-sudoku-helper.rakutest @@ -0,0 +1 @@ +../../killer-sudoku-helper.rakutest \ No newline at end of file diff --git a/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml b/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml new file mode 100644 index 00000000..d33c5842 --- /dev/null +++ b/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml @@ -0,0 +1,21 @@ +properties: + combinations: + test: |- + sprintf(q:to/END/, %case.raku, %case.raku, %case.List.raku, %case.map(*.List).List.raku, %case.raku); + cmp-ok( + killer-sudoku-helper(:sum(%s), :size(%s), :exclude(%s)), + "~~", + %s, + %s, + ); + END + +unit: module +example: |- + sub killer-sudoku-helper ( :$sum, :$size, :$exclude ) is export { + ( 1..9 ).combinations( $size ).grep( *.sum == $sum ).grep( *.none (elem) $exclude ) + } + +stub: |- + sub killer-sudoku-helper (:$sum, :$size, :$exclude) is export { + } diff --git a/exercises/practice/killer-sudoku-helper/.meta/tests.toml b/exercises/practice/killer-sudoku-helper/.meta/tests.toml new file mode 100644 index 00000000..19c23e8a --- /dev/null +++ b/exercises/practice/killer-sudoku-helper/.meta/tests.toml @@ -0,0 +1,49 @@ +# 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. + +[2aaa8f13-11b5-4054-b95c-a906e4d79fb6] +description = "Trivial 1-digit cages -> 1" + +[4645da19-9fdd-4087-a910-a6ed66823563] +description = "Trivial 1-digit cages -> 2" + +[07cfc704-f8aa-41b2-8f9a-cbefb674cb48] +description = "Trivial 1-digit cages -> 3" + +[22b8b2ba-c4fd-40b3-b1bf-40aa5e7b5f24] +description = "Trivial 1-digit cages -> 4" + +[b75d16e2-ff9b-464d-8578-71f73094cea7] +description = "Trivial 1-digit cages -> 5" + +[bcbf5afc-4c89-4ff6-9357-07ab4d42788f] +description = "Trivial 1-digit cages -> 6" + +[511b3bf8-186f-4e35-844f-c804d86f4a7a] +description = "Trivial 1-digit cages -> 7" + +[bd09a60d-3aca-43bd-b6aa-6ccad01bedda] +description = "Trivial 1-digit cages -> 8" + +[9b539f27-44ea-4ff8-bd3d-c7e136bee677] +description = "Trivial 1-digit cages -> 9" + +[0a8b2078-b3a4-4dbd-be0d-b180f503d5c3] +description = "Cage with sum 45 contains all digits 1:9" + +[2635d7c9-c716-4da1-84f1-c96e03900142] +description = "Cage with only 1 possible combination" + +[a5bde743-e3a2-4a0c-8aac-e64fceea4228] +description = "Cage with several combinations" + +[dfbf411c-737d-465a-a873-ca556360c274] +description = "Cage with several combinations that is restricted" diff --git a/exercises/practice/killer-sudoku-helper/KillerSudokuHelper.rakumod b/exercises/practice/killer-sudoku-helper/KillerSudokuHelper.rakumod new file mode 100644 index 00000000..11448f83 --- /dev/null +++ b/exercises/practice/killer-sudoku-helper/KillerSudokuHelper.rakumod @@ -0,0 +1,4 @@ +unit module KillerSudokuHelper; + +sub killer-sudoku-helper (:$sum, :$size, :$exclude) is export { +} diff --git a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest new file mode 100755 index 00000000..e3955f58 --- /dev/null +++ b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest @@ -0,0 +1,97 @@ +#!/usr/bin/env raku +use Test; +use lib $?FILE.IO.dirname; +use KillerSudokuHelper; + +cmp-ok( # begin: 2aaa8f13-11b5-4054-b95c-a906e4d79fb6 + killer-sudoku-helper(:sum(1), :size(1), :exclude(())), + "~~", + ((1,),), + "Trivial 1-digit cages: 1", +); # end: 2aaa8f13-11b5-4054-b95c-a906e4d79fb6 + +cmp-ok( # begin: 4645da19-9fdd-4087-a910-a6ed66823563 + killer-sudoku-helper(:sum(2), :size(1), :exclude(())), + "~~", + ((2,),), + "Trivial 1-digit cages: 2", +); # end: 4645da19-9fdd-4087-a910-a6ed66823563 + +cmp-ok( # begin: 07cfc704-f8aa-41b2-8f9a-cbefb674cb48 + killer-sudoku-helper(:sum(3), :size(1), :exclude(())), + "~~", + ((3,),), + "Trivial 1-digit cages: 3", +); # end: 07cfc704-f8aa-41b2-8f9a-cbefb674cb48 + +cmp-ok( # begin: 22b8b2ba-c4fd-40b3-b1bf-40aa5e7b5f24 + killer-sudoku-helper(:sum(4), :size(1), :exclude(())), + "~~", + ((4,),), + "Trivial 1-digit cages: 4", +); # end: 22b8b2ba-c4fd-40b3-b1bf-40aa5e7b5f24 + +cmp-ok( # begin: b75d16e2-ff9b-464d-8578-71f73094cea7 + killer-sudoku-helper(:sum(5), :size(1), :exclude(())), + "~~", + ((5,),), + "Trivial 1-digit cages: 5", +); # end: b75d16e2-ff9b-464d-8578-71f73094cea7 + +cmp-ok( # begin: bcbf5afc-4c89-4ff6-9357-07ab4d42788f + killer-sudoku-helper(:sum(6), :size(1), :exclude(())), + "~~", + ((6,),), + "Trivial 1-digit cages: 6", +); # end: bcbf5afc-4c89-4ff6-9357-07ab4d42788f + +cmp-ok( # begin: 511b3bf8-186f-4e35-844f-c804d86f4a7a + killer-sudoku-helper(:sum(7), :size(1), :exclude(())), + "~~", + ((7,),), + "Trivial 1-digit cages: 7", +); # end: 511b3bf8-186f-4e35-844f-c804d86f4a7a + +cmp-ok( # begin: bd09a60d-3aca-43bd-b6aa-6ccad01bedda + killer-sudoku-helper(:sum(8), :size(1), :exclude(())), + "~~", + ((8,),), + "Trivial 1-digit cages: 8", +); # end: bd09a60d-3aca-43bd-b6aa-6ccad01bedda + +cmp-ok( # begin: 9b539f27-44ea-4ff8-bd3d-c7e136bee677 + killer-sudoku-helper(:sum(9), :size(1), :exclude(())), + "~~", + ((9,),), + "Trivial 1-digit cages: 9", +); # end: 9b539f27-44ea-4ff8-bd3d-c7e136bee677 + +cmp-ok( # begin: 0a8b2078-b3a4-4dbd-be0d-b180f503d5c3 + killer-sudoku-helper(:sum(45), :size(9), :exclude(())), + "~~", + ((1, 2, 3, 4, 5, 6, 7, 8, 9),), + "Cage with sum 45 contains all digits 1:9", +); # end: 0a8b2078-b3a4-4dbd-be0d-b180f503d5c3 + +cmp-ok( # begin: 2635d7c9-c716-4da1-84f1-c96e03900142 + killer-sudoku-helper(:sum(7), :size(3), :exclude(())), + "~~", + ((1, 2, 4),), + "Cage with only 1 possible combination", +); # end: 2635d7c9-c716-4da1-84f1-c96e03900142 + +cmp-ok( # begin: a5bde743-e3a2-4a0c-8aac-e64fceea4228 + killer-sudoku-helper(:sum(10), :size(2), :exclude(())), + "~~", + ((1, 9), (2, 8), (3, 7), (4, 6)), + "Cage with several combinations", +); # end: a5bde743-e3a2-4a0c-8aac-e64fceea4228 + +cmp-ok( # begin: dfbf411c-737d-465a-a873-ca556360c274 + killer-sudoku-helper(:sum(10), :size(2), :exclude((1, 4))), + "~~", + ((2, 8), (3, 7)), + "Cage with several combinations that is restricted", +); # end: dfbf411c-737d-465a-a873-ca556360c274 + +done-testing; From f7e94829b694ca8339531641378970d86d2c4ed4 Mon Sep 17 00:00:00 2001 From: Daniel Mita Date: Sat, 24 Jun 2023 21:09:28 +0100 Subject: [PATCH 2/3] Modify exclude, use set equality check --- .../.meta/template-data.yaml | 4 +- .../killer-sudoku-helper.rakutest | 52 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml b/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml index d33c5842..50f31bd5 100644 --- a/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml +++ b/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml @@ -3,8 +3,8 @@ properties: test: |- sprintf(q:to/END/, %case.raku, %case.raku, %case.List.raku, %case.map(*.List).List.raku, %case.raku); cmp-ok( - killer-sudoku-helper(:sum(%s), :size(%s), :exclude(%s)), - "~~", + killer-sudoku-helper( :sum(%s), :size(%s), :exclude%s ), + "(==)", %s, %s, ); diff --git a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest index e3955f58..88e14350 100755 --- a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest +++ b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest @@ -4,92 +4,92 @@ use lib $?FILE.IO.dirname; use KillerSudokuHelper; cmp-ok( # begin: 2aaa8f13-11b5-4054-b95c-a906e4d79fb6 - killer-sudoku-helper(:sum(1), :size(1), :exclude(())), - "~~", + killer-sudoku-helper( :sum(1), :size(1), :exclude() ), + "(==)", ((1,),), "Trivial 1-digit cages: 1", ); # end: 2aaa8f13-11b5-4054-b95c-a906e4d79fb6 cmp-ok( # begin: 4645da19-9fdd-4087-a910-a6ed66823563 - killer-sudoku-helper(:sum(2), :size(1), :exclude(())), - "~~", + killer-sudoku-helper( :sum(2), :size(1), :exclude() ), + "(==)", ((2,),), "Trivial 1-digit cages: 2", ); # end: 4645da19-9fdd-4087-a910-a6ed66823563 cmp-ok( # begin: 07cfc704-f8aa-41b2-8f9a-cbefb674cb48 - killer-sudoku-helper(:sum(3), :size(1), :exclude(())), - "~~", + killer-sudoku-helper( :sum(3), :size(1), :exclude() ), + "(==)", ((3,),), "Trivial 1-digit cages: 3", ); # end: 07cfc704-f8aa-41b2-8f9a-cbefb674cb48 cmp-ok( # begin: 22b8b2ba-c4fd-40b3-b1bf-40aa5e7b5f24 - killer-sudoku-helper(:sum(4), :size(1), :exclude(())), - "~~", + killer-sudoku-helper( :sum(4), :size(1), :exclude() ), + "(==)", ((4,),), "Trivial 1-digit cages: 4", ); # end: 22b8b2ba-c4fd-40b3-b1bf-40aa5e7b5f24 cmp-ok( # begin: b75d16e2-ff9b-464d-8578-71f73094cea7 - killer-sudoku-helper(:sum(5), :size(1), :exclude(())), - "~~", + killer-sudoku-helper( :sum(5), :size(1), :exclude() ), + "(==)", ((5,),), "Trivial 1-digit cages: 5", ); # end: b75d16e2-ff9b-464d-8578-71f73094cea7 cmp-ok( # begin: bcbf5afc-4c89-4ff6-9357-07ab4d42788f - killer-sudoku-helper(:sum(6), :size(1), :exclude(())), - "~~", + killer-sudoku-helper( :sum(6), :size(1), :exclude() ), + "(==)", ((6,),), "Trivial 1-digit cages: 6", ); # end: bcbf5afc-4c89-4ff6-9357-07ab4d42788f cmp-ok( # begin: 511b3bf8-186f-4e35-844f-c804d86f4a7a - killer-sudoku-helper(:sum(7), :size(1), :exclude(())), - "~~", + killer-sudoku-helper( :sum(7), :size(1), :exclude() ), + "(==)", ((7,),), "Trivial 1-digit cages: 7", ); # end: 511b3bf8-186f-4e35-844f-c804d86f4a7a cmp-ok( # begin: bd09a60d-3aca-43bd-b6aa-6ccad01bedda - killer-sudoku-helper(:sum(8), :size(1), :exclude(())), - "~~", + killer-sudoku-helper( :sum(8), :size(1), :exclude() ), + "(==)", ((8,),), "Trivial 1-digit cages: 8", ); # end: bd09a60d-3aca-43bd-b6aa-6ccad01bedda cmp-ok( # begin: 9b539f27-44ea-4ff8-bd3d-c7e136bee677 - killer-sudoku-helper(:sum(9), :size(1), :exclude(())), - "~~", + killer-sudoku-helper( :sum(9), :size(1), :exclude() ), + "(==)", ((9,),), "Trivial 1-digit cages: 9", ); # end: 9b539f27-44ea-4ff8-bd3d-c7e136bee677 cmp-ok( # begin: 0a8b2078-b3a4-4dbd-be0d-b180f503d5c3 - killer-sudoku-helper(:sum(45), :size(9), :exclude(())), - "~~", + killer-sudoku-helper( :sum(45), :size(9), :exclude() ), + "(==)", ((1, 2, 3, 4, 5, 6, 7, 8, 9),), "Cage with sum 45 contains all digits 1:9", ); # end: 0a8b2078-b3a4-4dbd-be0d-b180f503d5c3 cmp-ok( # begin: 2635d7c9-c716-4da1-84f1-c96e03900142 - killer-sudoku-helper(:sum(7), :size(3), :exclude(())), - "~~", + killer-sudoku-helper( :sum(7), :size(3), :exclude() ), + "(==)", ((1, 2, 4),), "Cage with only 1 possible combination", ); # end: 2635d7c9-c716-4da1-84f1-c96e03900142 cmp-ok( # begin: a5bde743-e3a2-4a0c-8aac-e64fceea4228 - killer-sudoku-helper(:sum(10), :size(2), :exclude(())), - "~~", + killer-sudoku-helper( :sum(10), :size(2), :exclude() ), + "(==)", ((1, 9), (2, 8), (3, 7), (4, 6)), "Cage with several combinations", ); # end: a5bde743-e3a2-4a0c-8aac-e64fceea4228 cmp-ok( # begin: dfbf411c-737d-465a-a873-ca556360c274 - killer-sudoku-helper(:sum(10), :size(2), :exclude((1, 4))), - "~~", + killer-sudoku-helper( :sum(10), :size(2), :exclude(1, 4) ), + "(==)", ((2, 8), (3, 7)), "Cage with several combinations that is restricted", ); # end: dfbf411c-737d-465a-a873-ca556360c274 From e0f1e7c8d059805625cb49a433eb6b086df1e44d Mon Sep 17 00:00:00 2001 From: Daniel Mita Date: Sat, 24 Jun 2023 21:19:28 +0100 Subject: [PATCH 3/3] Readme states combinations must be sorted --- .../.meta/template-data.yaml | 2 +- .../killer-sudoku-helper.rakutest | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml b/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml index 50f31bd5..64f25a63 100644 --- a/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml +++ b/exercises/practice/killer-sudoku-helper/.meta/template-data.yaml @@ -4,7 +4,7 @@ properties: sprintf(q:to/END/, %case.raku, %case.raku, %case.List.raku, %case.map(*.List).List.raku, %case.raku); cmp-ok( killer-sudoku-helper( :sum(%s), :size(%s), :exclude%s ), - "(==)", + "~~", %s, %s, ); diff --git a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest index 88e14350..0aea3225 100755 --- a/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest +++ b/exercises/practice/killer-sudoku-helper/killer-sudoku-helper.rakutest @@ -5,91 +5,91 @@ use KillerSudokuHelper; cmp-ok( # begin: 2aaa8f13-11b5-4054-b95c-a906e4d79fb6 killer-sudoku-helper( :sum(1), :size(1), :exclude() ), - "(==)", + "~~", ((1,),), "Trivial 1-digit cages: 1", ); # end: 2aaa8f13-11b5-4054-b95c-a906e4d79fb6 cmp-ok( # begin: 4645da19-9fdd-4087-a910-a6ed66823563 killer-sudoku-helper( :sum(2), :size(1), :exclude() ), - "(==)", + "~~", ((2,),), "Trivial 1-digit cages: 2", ); # end: 4645da19-9fdd-4087-a910-a6ed66823563 cmp-ok( # begin: 07cfc704-f8aa-41b2-8f9a-cbefb674cb48 killer-sudoku-helper( :sum(3), :size(1), :exclude() ), - "(==)", + "~~", ((3,),), "Trivial 1-digit cages: 3", ); # end: 07cfc704-f8aa-41b2-8f9a-cbefb674cb48 cmp-ok( # begin: 22b8b2ba-c4fd-40b3-b1bf-40aa5e7b5f24 killer-sudoku-helper( :sum(4), :size(1), :exclude() ), - "(==)", + "~~", ((4,),), "Trivial 1-digit cages: 4", ); # end: 22b8b2ba-c4fd-40b3-b1bf-40aa5e7b5f24 cmp-ok( # begin: b75d16e2-ff9b-464d-8578-71f73094cea7 killer-sudoku-helper( :sum(5), :size(1), :exclude() ), - "(==)", + "~~", ((5,),), "Trivial 1-digit cages: 5", ); # end: b75d16e2-ff9b-464d-8578-71f73094cea7 cmp-ok( # begin: bcbf5afc-4c89-4ff6-9357-07ab4d42788f killer-sudoku-helper( :sum(6), :size(1), :exclude() ), - "(==)", + "~~", ((6,),), "Trivial 1-digit cages: 6", ); # end: bcbf5afc-4c89-4ff6-9357-07ab4d42788f cmp-ok( # begin: 511b3bf8-186f-4e35-844f-c804d86f4a7a killer-sudoku-helper( :sum(7), :size(1), :exclude() ), - "(==)", + "~~", ((7,),), "Trivial 1-digit cages: 7", ); # end: 511b3bf8-186f-4e35-844f-c804d86f4a7a cmp-ok( # begin: bd09a60d-3aca-43bd-b6aa-6ccad01bedda killer-sudoku-helper( :sum(8), :size(1), :exclude() ), - "(==)", + "~~", ((8,),), "Trivial 1-digit cages: 8", ); # end: bd09a60d-3aca-43bd-b6aa-6ccad01bedda cmp-ok( # begin: 9b539f27-44ea-4ff8-bd3d-c7e136bee677 killer-sudoku-helper( :sum(9), :size(1), :exclude() ), - "(==)", + "~~", ((9,),), "Trivial 1-digit cages: 9", ); # end: 9b539f27-44ea-4ff8-bd3d-c7e136bee677 cmp-ok( # begin: 0a8b2078-b3a4-4dbd-be0d-b180f503d5c3 killer-sudoku-helper( :sum(45), :size(9), :exclude() ), - "(==)", + "~~", ((1, 2, 3, 4, 5, 6, 7, 8, 9),), "Cage with sum 45 contains all digits 1:9", ); # end: 0a8b2078-b3a4-4dbd-be0d-b180f503d5c3 cmp-ok( # begin: 2635d7c9-c716-4da1-84f1-c96e03900142 killer-sudoku-helper( :sum(7), :size(3), :exclude() ), - "(==)", + "~~", ((1, 2, 4),), "Cage with only 1 possible combination", ); # end: 2635d7c9-c716-4da1-84f1-c96e03900142 cmp-ok( # begin: a5bde743-e3a2-4a0c-8aac-e64fceea4228 killer-sudoku-helper( :sum(10), :size(2), :exclude() ), - "(==)", + "~~", ((1, 9), (2, 8), (3, 7), (4, 6)), "Cage with several combinations", ); # end: a5bde743-e3a2-4a0c-8aac-e64fceea4228 cmp-ok( # begin: dfbf411c-737d-465a-a873-ca556360c274 killer-sudoku-helper( :sum(10), :size(2), :exclude(1, 4) ), - "(==)", + "~~", ((2, 8), (3, 7)), "Cage with several combinations that is restricted", ); # end: dfbf411c-737d-465a-a873-ca556360c274