Mon, 20 Jun 2005

Solving Sudoku in C and Python

As an intellectual exercise (I hate puzzles) I wrote a quick C program to solve sudoku puzzles. Then I wrote a Python version (almost, but not quite, "my first python program").

The python was shorter, 150 lines, vs C 260 lines. Time to code is not comparable since I am not fluent in Python, but I can believe that the Python version would have been quicker to write if I was. But hacking both versions to loop 100 times reveals the Python is about 192 times slower (oops, fixed, now 120 times slower). So it's not free.

I talked to Chris about writing a C++ version (presumably using an STL Set), which would be another data point. I'd do a Z80 asm version, except I'm not sure where to get a Z80 assembler these days.


[/tech] permanent link