Journal home page
General information
Submit an item
Download style files
Copyright
Contact us
logo for The PracTeX Journal TUG logo

Distractions Answers

The Editors

Sudoku - a simple yet challenging puzzle

There were several excellent entries in this contest — well, four to be exact, but each showed great ingenuity in using TeX to solve these challenging puzzles. You are invited to review their solutions and the LaTeX and TeX macros they used.


sudoku grid

Sudoku rules: Complete the grid so that every row, column, and 3-by-3 box contains every digit, 1 to 9.

The contest: Typeset this grid using TeX macros. You may use LaTeX, ConTeXt, plain TeX, AMSTeX, or your favorite set of macros.

Beginners category. Typeset the grid as shown above. This category is open to those who have been using TeX for less than one year.

     There were no entries in this category.

Regular category. Create a new macro, \sudoku{file}, which reads a sudoku puzzle file and then typesets the grid. A sudoku puzzle file is a simple text file with nine lines, and each line has nine characters: the digits 1-9 or (.) for a blank square.

     There were two winners in this category: Dave Morris (University of Lethbridge, Canada), and Peter Wilson (Herries Press, WA).

     Dave Morris's macros, an example using his macros, and a pdf showing his result.

     Peter Wilson's macros and pdf.

For Wizards only. Create a new macro, \sudokusolve{file}, which which reads an easy sudoku puzzle file, solves it, and then typesets the solved grid.

     There were two winners in this category: Zachary Catlin (Purdue University), and Peter Wilson (Herries Press, WA).

     Zachary's solver.

     Peter's solver, and a pdf.


The Distractions editor suggested comparing the two solvers, and both Zachary and Peter agreed to run their solvers through a series of puzzles of varying difficulty. Both were amazingly good at solving a variety of puzzles, including a high percentage of difficult ones. Their results are summarized in these files:

     Peter Wilson's test files

     Zachary Catlin's test results

Peter Wilson notes that he has continued work on his Sudoku macros, and plans to contribute a "sudokubundle" to CTAN soon which includes a Sudoku typesetter, solver, and puzzle generator. Also on CTAN is Paul Abraham's Sudoku package for typesetting puzzles.