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.
For a more detailed explanation, check out this guide.
In a 3-digit cage with a sum of 7, there is only one valid combination: 124.
In a 2-digit cage with a sum 10, there are 4 possible combinations:
In a 2-digit cage with a sum 10, where the column already contains a 1 and a 4, there are 2 possible combinations:
19 and 46 are not possible due to the 1 and 4 in the column according to standard Sudoku rules.
If you want to give an approachable Killer Sudoku a go, you can try out this puzzle by Clover, featured by Mark Goodliffe on Cracking The Cryptic on the 21st of June 2021.
You can also find Killer Sudokus in varying difficulty in numerous newspapers, as well as Sudoku apps, books and websites.
The screenshots above have been generated using F-Puzzles.com, a Puzzle Setting Tool by Eric Fox.
Sign up to Exercism to learn and master Raku with 78 exercises, and real human mentoring, all for free.