Well, I’ve programmed my first Sudoku puzzle generator. I developed the generator in Ruby, first using Eclipse and the Ruby addon (Eclipse runs better on my mac than Netbeans), and later I downloaded a trial of Textmate. Here’s a sample Sudoku created by my program:
| 2 | 1 | 8 | 4 | 9 | ||||
| 2 | 9 | 3 | 8 | 4 | 6 | 1 | ||
| 4 | 8 | 9 | 5 | 3 | 2 | |||
| 6 | 7 | 9 | 1 | 5 | 3 | |||
| 1 | 7 | 3 | 5 | 2 | ||||
| 3 | 9 | 1 | 2 | |||||
| 8 | 5 | 2 | 4 | 3 | 9 | 6 | ||
| 9 | 8 | 6 | 1 | 4 | ||||
| 9 | 6 | 4 | 3 | 2 | 8 | 5 |
They’re not the most sophisticated Sudoku puzzles, I still need to study the logic of a Sudoku a bit more to figure out how to produce more challenging puzzles. I’ve taken on the design of a generating algorithm as a personal challenge and have yet to refer to any tutorials or written materials on how to generate Sudoku puzzles–I figured it out all myself. This isn’t neccesarily the best approach to solving a problem, it’s good to refer to other people’s work, but I’ve taken on this problem as a challenge. Eventually, I’ll read what others have written on the subject. I know that Donald Knuth as done a lot of research on Sudoku puzzles and “chained algorithms.” No, I haven’t read his paper yet, just looked at the abstract.
I love constructing a program that follows a particular model of a problem rather than just trying to solve the problem step by step. In programming languages this past winter, I built a simple language parser. It may have not been the most optimal algorithm, but it did model the problem very well. I created classes that modelled a syntax tree, and then created the tree by linking my objects together.
Related posts: