Watch that tango!

Posted on March 3, 2008, under Programming

Wife: Dancing lynx? That would be really cute. Of course, they’d have to get fitted for special little shoes, if they were going to be, like, tap-dancing or anything. Still…

Me: It’s links. With an “i”.

Wife: Yes, I know that, but it would be much cuter if it was a bobcat.

Me: And less useful.

Yesterday I implemented the Dancing Links algorithm. I first heard about it a few years ago after I wrote a simple Sudoku game. I didn’t write a version back then because I had tired of writing Yet Another Sudoku Game, and my game languished and was forgotten. This time, however, my current project could benefit from it.

It is a surprisingly easy algorithm to write. With the way people talk about it—and with some of the implementations I have seen—I was expecting it to be a long, drawn out battle to get it done. Not so! It was the work of maybe a few hours to read about it and get it completed. Now I just need to see if it will work for my purposes. 😛

3 comments

Angel says:

March 27, 2008 at 7:21 pm

If possible obtain the code for Sudoku with Dancing Link algoritm?.

Thanks a lot

Graeme says:

March 28, 2008 at 4:38 pm

I implemented the dancing links algorithm for a different project, not for a Sudoku game. The source of my implementation is available here, along with some sample code that recreates Donald Knuth’s example matrix and solution.

However, writing another Sudoku game does sound like a nice break from my current project, so I might just do that.

Angel says:

March 29, 2008 at 2:24 am

Thanks a lot.

Categories