XP is just a number PerlMonks

### KenKen puzzle helper

by toolic (Bishop)
 on Sep 16, 2021 at 21:51 UTC Need Help??

The most common mistake I make when solving KenKen puzzles is that I fail to enumerate all the correct combinations that could fill a cage. It can be tedious (and hence error-prone) to think up all the combinations for larger addition and multiplication cages.

This is not intended to be part of a complete puzzle solver. I just want to use it to "check my math" after I realize I made a mistake while working on a puzzle.

Since I don't have tests for the code, there could be bugs. One limitation is that it does not account for the shape of a cage. Depending on the shape, some cages forbid the same number appearing more than once, while others allow one or more numbers to appear multiple times. There is an option to control the number of duplicates to some degree.

Here is an example output for a 9x9 grid with a cage size of 5, and the numbers adding up to 29:

kenken -c 5 -n 29 -r 2 Grid size: 9 Cage size: 5 Operator : a Number : 29 Reject : 2 29+ = 1 + 4 + 7 + 8 + 9 29+ = 1 + 5 + 6 + 8 + 9 29+ = 2 + 3 + 7 + 8 + 9 29+ = 2 + 4 + 6 + 8 + 9 29+ = 2 + 5 + 6 + 7 + 9 29+ = 3 + 4 + 5 + 8 + 9 29+ = 3 + 4 + 6 + 7 + 9 29+ = 3 + 5 + 6 + 7 + 8 Combinations = 8

For this run, I rejected all duplicates. If I rerun allowing numbers to appear twice, the number of combinations jumps up to 48.

I was surprised at how little of my own code I had to write because it leverages so heavily on CPAN and Core modules.

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://11136838]
Approved by hippo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2021-11-27 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?

No recent polls found

Notices?