I ported the Python KenKen solver I was playing with last week over to JavaScript, and wrapped a GUI around it. You can check out the resulting web-based KenKen solver, if you’re interested.
Bibliography
I’ve written a lot of articles about the KenKen solver; here’s a concise listing of them.
- KenKen vs. Sudoku: A discussion of the differences between the KenKen and Sudoku number-placement games, with an eye towards their manipulation by software
- Constraint design: A discussion of the role of Constraints in a KenKen solver
- Constraint objects: A first implementation of Constraint objects
- Puzzle representation: A discussion of machine-readable KenKen puzzles
- Solver search algorithm: The core search and constraint-propagation algorithm
- Performance tuning (Part 1): A discussion of performance tuning tools, and a 1-line change that cuts execution time by 30%
- Performance tuning (Part 2): Simple utility function optimizations yield another 20%
- Performance tuning (Part 3): Two broader changes in strategy yield another 40%
- Generalization to (Jigsaw) Sudoku: A one-line change makes the solver compatible with Jigsaw Sudoku
JavaScript vs. Python
I’ve always been partial to JavaScript, but I’ve been soured on it by this porting project. Little things like the lack of (true) associative arrays, and big things like the lack of list comprehensions, seem to make JavaScript awfully clunky compared to Python. (I speak here of JS as it actually exists in browsers, not as it might exist, in more sophisticated forms, elsewhere.)
Toolkits such as MochiKit do seem to help somewhat, but I can’t say that programming JS is fun in the way that programming Python is. The language always seems to be a little wordier than necessary.
Of course, your mileage may vary. And I’m still a big fan of JSON, and wish Python had JS-style support for object literals.