-
-
Notifications
You must be signed in to change notification settings - Fork 554
Add exercise: killer-sudoku-helper #2007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
{ | ||
"exercise": "killer-sudoku-helper", | ||
"cases": [ | ||
{ | ||
"description": "Trivial 1-digit cages", | ||
"cases": [ | ||
{ | ||
"uuid": "2aaa8f13-11b5-4054-b95c-a906e4d79fb6", | ||
"description": "1", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 1, | ||
"size": 1, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[1]] | ||
}, | ||
{ | ||
"uuid": "4645da19-9fdd-4087-a910-a6ed66823563", | ||
"description": "2", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 2, | ||
"size": 1, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[2]] | ||
}, | ||
{ | ||
"uuid": "07cfc704-f8aa-41b2-8f9a-cbefb674cb48", | ||
"description": "3", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 3, | ||
"size": 1, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[3]] | ||
}, | ||
{ | ||
"uuid": "22b8b2ba-c4fd-40b3-b1bf-40aa5e7b5f24", | ||
"description": "4", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 4, | ||
"size": 1, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[4]] | ||
}, | ||
{ | ||
"uuid": "b75d16e2-ff9b-464d-8578-71f73094cea7", | ||
"description": "5", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 5, | ||
"size": 1, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[5]] | ||
}, | ||
{ | ||
"uuid": "bcbf5afc-4c89-4ff6-9357-07ab4d42788f", | ||
"description": "6", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 6, | ||
"size": 1, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[6]] | ||
}, | ||
{ | ||
"uuid": "511b3bf8-186f-4e35-844f-c804d86f4a7a", | ||
"description": "7", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 7, | ||
"size": 1, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[7]] | ||
}, | ||
{ | ||
"uuid": "bd09a60d-3aca-43bd-b6aa-6ccad01bedda", | ||
"description": "8", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 8, | ||
"size": 1, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[8]] | ||
}, | ||
{ | ||
"uuid": "9b539f27-44ea-4ff8-bd3d-c7e136bee677", | ||
"description": "9", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 9, | ||
"size": 1, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[9]] | ||
} | ||
] | ||
}, | ||
{ | ||
"uuid": "0a8b2078-b3a4-4dbd-be0d-b180f503d5c3", | ||
"description": "Cage with sum 45 contains all digits 1:9", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 45, | ||
"size": 9, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[1, 2, 3, 4, 5, 6, 7, 8, 9]] | ||
}, | ||
{ | ||
"uuid": "2635d7c9-c716-4da1-84f1-c96e03900142", | ||
"description": "Cage with only 1 possible combination", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 7, | ||
"size": 3, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[1, 2, 4]] | ||
}, | ||
{ | ||
"uuid": "a5bde743-e3a2-4a0c-8aac-e64fceea4228", | ||
"description": "Cage with several combinations", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 10, | ||
"size": 2, | ||
"exclude": [] | ||
} | ||
}, | ||
"expected": [[1, 9], [2, 8], [3, 7], [4, 6]] | ||
}, | ||
{ | ||
"uuid": "dfbf411c-737d-465a-a873-ca556360c274", | ||
"description": "Cage with several combinations that is restricted", | ||
"property": "combinations", | ||
"input": { | ||
"cage": { | ||
"sum": 10, | ||
"size": 2, | ||
"exclude": [1, 4] | ||
} | ||
}, | ||
"expected": [[2, 8], [3, 7]] | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Description | ||
|
||
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](https://masteringsudoku.com/sudoku-rules-beginners/) 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](https://masteringsudoku.com/killer-sudoku/). | ||
|
||
## 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. | ||
|
||
 | ||
|
||
## Example 2: Cage with several combinations | ||
|
||
In a 2-digit cage with a sum 10, there are 4 possible combinations: | ||
|
||
- 19 | ||
- 28 | ||
- 37 | ||
- 46 | ||
|
||
 | ||
|
||
## 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. | ||
|
||
 | ||
|
||
## Trying it yourself | ||
|
||
If you want to give an approachable Killer Sudoku a go, you can try out [this puzzle](https://app.crackingthecryptic.com/sudoku/HqTBn3Pr6R) by Clover, featured by [Mark Goodliffe on Cracking The Cryptic on the 21st of June 2021](https://youtu.be/c_NjEbFEeW0?t=1180). | ||
|
||
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
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" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.