Solving KenKen – ASP.NET hobby project

Were you bad at math in school? Did your childhood nightmares involve floating ÷ ? If so, your math teacher was unfortunately not Tetsuya Miyamoto.

Tetsuya Miyamoto, a very intelligent math teacher from Japan is the inventor of the logic puzzle KenKen1. Tetsuya believed in the art of teaching without teaching and learnt how not to scare his pupils away! KenKen which loosely means cleverness squared (ken X ken) is very much like Sudoku with the addition of simple mathematical rules.

I love KenKen and have been addicted to it for some time now. So early one morning I decided I’d write a computer program to solve it. At first I thought it was going to be a piece of cake. One day is all it would take. After all, how hard was it to find the list of numbers that multiply to twenty four? Turns out, it was; not hard but definitely tricky. Then again, which software project ever completed within estimates ;-)

I wrote the project in C# (ASP.NET) but I wonder if F# would have been a better choice given the mathematical nature of the problem. The lazy me, who didn’t want to learn another syntax sadly skipped this. Maybe I can write an F# program to solve Sudoku ?

My program is not exactly a computerized solution to KenKen. It moves one step at a time and mimics the way a human being (mostly me) would typically solve this puzzle. This also means that the success of this approach is limited by my ability to solve it. I personally have not been able to solve a 7 x 7 hard puzzle and hence, my program can’t solve it either (any help appreciated !). The solution also doesn’t use backtracking2 because although it is very easy for a computer, it is very hard for a human being after a certain level.

So, this is how the application looks. It has been deployed using AppHarbor3 and you can check it out over here (kenken.apphb.com).

This is what those numbers mean !

So check it out, have some fun and keep that brain running ;-)

  1. KenKen® is a registered trademark of Nextoy, LLC. Puzzle content ©2011 KenKen Puzzle LLC. (www.kenken.com)
  2. Backtracking is a common technique in computer science used for finding solutions to certain problems. In simple words, you guess a solution and then move forward. If your guess was invalid you wont be able to solve the problem correctly and you will discard this solution. You then backtrack, and guess again, till finally your guess is accurate!
  3. AppHarbor allows you to deploy your application on the web and was such a joy to use (appharbor.com)
Advertisements