On solving Cross Sums

As you may remember, I’ve become obsessed with the Dell Magazines puzzle collections:

This book of mine has many types of puzzles, most of which are word-based (without being dreadful crosswords, which I suck at) or logic-based (which I love, given my career).

One such puzzle of theirs that I’d never heard of before is called cross sums 1Also known as Kakuro, these apparently predate Sudoku.. It combines the interconnectedness of crosswords with some Sudoku ground rules, along with some simple arithmetic. It’s a simple premise but a surprisingly difficult puzzle to solve.

Dell has published a little “cheat sheet” of possible sums for aiding quick reference while solving:

This little guide has been helpful, but I pretty quickly saw that it was missing some other helpful hints, such as: “which digits, 1-9, are missing in this set?” That could be helpful too!

So then I began to think that this would make an excellent programming challenge, to develop and algorithm that would parse through all the available combinations of digits that add up to specific sums, for any width of digits, 2-9.

My goto language lately for simple text parsing has been AutoHotkey. It’s powerful, weakly typed, flexible, small footprint, good support, and simple to use. It proved a good little solution for this job.

Codes

You can see my results on GitHub.

The output that is produced looks like this:

6 = 1+2+3; 	(4, 5, 6, 7, 8, 9)
7 = 1+2+4; 	(3, 5, 6, 7, 8, 9)
8 = 1+2+5; 	1+3+4; 	(6, 7, 8, 9)
9 = 1+2+6; 	1+3+5; 	2+3+4; 	(7, 8, 9)
10 = 1+2+7; 	1+3+6; 	1+4+5; 	2+3+5; 	(8, 9)
11 = 1+2+8; 	1+3+7; 	1+4+6; 	2+3+6; 	2+4+5; 	(9)
12 = 1+2+9; 	1+3+8; 	1+4+7; 	1+5+6; 	2+3+7; 	2+4+6; 	3+4+5; 	
13 = 1+3+9; 	1+4+8; 	1+5+7; 	2+3+8; 	2+4+7; 	2+5+6; 	3+4+6; 	
14 = 1+4+9; 	1+5+8; 	1+6+7; 	2+3+9; 	2+4+8; 	2+5+7; 	3+4+7; 	3+5+6; 	
15 = 1+5+9; 	1+6+8; 	2+4+9; 	2+5+8; 	2+6+7; 	3+4+8; 	3+5+7; 	4+5+6; 	
16 = 1+6+9; 	1+7+8; 	2+5+9; 	2+6+8; 	3+4+9; 	3+5+8; 	3+6+7; 	4+5+7; 	
17 = 1+7+9; 	2+6+9; 	2+7+8; 	3+5+9; 	3+6+8; 	4+5+8; 	4+6+7; 	
18 = 1+8+9; 	2+7+9; 	3+6+9; 	3+7+8; 	4+5+9; 	4+6+8; 	5+6+7; 	
19 = 2+8+9; 	3+7+9; 	4+6+9; 	4+7+8; 	5+6+8; 	(1)
20 = 3+8+9; 	4+7+9; 	5+6+9; 	5+7+8; 	(1, 2)
21 = 4+8+9; 	5+7+9; 	6+7+8; 	(1, 2, 3)
22 = 5+8+9; 	6+7+9; 	(1, 2, 3, 4)
23 = 6+8+9; 	(1, 2, 3, 4, 5, 7)
24 = 7+8+9; 	(1, 2, 3, 4, 5, 6)

The numbers in parentheses are digits that aren’t used to make the sum options. For instance, from above, the result 22 is a sum of 5, 8, 9 only. No other digits 1-9 can be used to get to 22.

As you might imagine, this algorithm required some recursion, which is a topic that I haven’t delved into much. It was a good homework exercise for me.

As fun and challenging as all this has been, it still only scratches the surface of the actual solving of these puzzles. Here is an excellent site for helping with the various methods.

Footnotes

  • 1
    Also known as Kakuro, these apparently predate Sudoku.

Posted

in

by

Modified:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.