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)
About these ads

8 Comments

  1. Amit
    Posted May 17, 2011 at 12:34 pm | Permalink | Reply

    Slick interface. Where’s the source ?

    • Posted May 17, 2011 at 5:21 pm | Permalink | Reply

      Thanks for checking it out ! Just looked up AppHarbour for a way to expose the source code, but I don’t think that is possible. I will host the code in BitBucket or GitHub and sync that up with AppHarbor. Will post an update and source code link when done !

    • Posted May 20, 2011 at 6:40 pm | Permalink | Reply

      The source code is now available on GitHub over here, https://github.com/pedul/KenKen

  2. Praful
    Posted May 17, 2011 at 2:10 pm | Permalink | Reply

    Nice blog and nice app!! :)

    Lets go Sudoku and F# :)

  3. Posted May 23, 2011 at 1:27 pm | Permalink | Reply

    That’s a nice!!

  4. Steve Langfelder
    Posted August 17, 2011 at 8:43 pm | Permalink | Reply

    Hi Preeti,

    I have a human solution to your 7 x 7 “unsolved” puzzle. If you’d like to see it, reply to me personally. My email address is Langfelder@aol.com

    I tried reaching you via Spoke but was unwilling to join. I don’t link up with social networks. Hope to hear from you.

    Regards,

    Steve

    Stephen B. Langfelder
    31 Mulford Drive
    Wayne, NJ 07470
    973-633-1802
    email: Langfelder@aol.com

One Trackback

  1. By Big Bad Sudoku on December 15, 2011 at 8:58 am

    Awsome site…

    There is noticeably a lot to know regarding this. I suppose you created certain nice points in features additionally….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: