About

Take a tour of my mind.

Search for content

The Sudoku Challenge

I’ve decided to stop being lazy and finally start learning the intricacies of several programming languages that I have always been interested in. A little background: I would say that I have a strong knowledge of C, Java, and Python. Although I have used Ruby back in high school, I feel that I have lost touch with it. There are also various new features in Ruby 1.9 that I would like to try. Aside from imperative languages, I really want to delve into the new functional programming paradigm.

So what is the Sudoku Challenge? Well, I happened to stumble upon a sudoku solver I wrote in Python in my AI class in high school. It uses a graph coloring algorithm and forward checking heuristic to solve any standard Sudoku in no time (it solves so called “Evil” puzzles in a tenth of a second with I/O overhead included).

Here is the unadulterated source for sudoku.py:

Although this is clearly fast enough (just ran at 0.135s), I would like to try to write this solver as cleanly and efficiently as possible in several other languages. In the process, I hope to utilize unique aspects of the chosen language to clarify and speed up my code. I will post detailed runtime analysis comparisons and file length counts in order to see which version is the fastest/shortest. If I can write a blazing fast solver in a language, chances are that I understand its nuances.

Up next is the Ruby version…