Volume 9, Issue 3

Articles
In and Out
Trott's Corner
New Products
New Publications
Calendar
News Bulletins
New Resources
Letters
Classifieds

Editorial Policy
Staff and Contributors
Submissions
Subscriptions
Back Issues
Contact Information

In and Out

# In-flight Puzzle

Q: This puzzle appeared in an in-flight magazine: In the following diagram, place the numbers 1 through 9 so that each row, column, and subsquare contains each number exactly once.

How can I solve this using Mathematica?

A: Bobby Treat (drbob@bigfoot.com) answers: Here is a naïve solution that depends on there being, at each stage, at least one cell that is fully determined and that does not check for contradictions. It works for the sort of problem you would expect to encounter in an in-flight magazine.

Input the table with empty cells replaced by empty lists.

PuzzleDisplay, written by David Park (djmp@earthlink.net), is used to display the puzzle.

The function SubSquare finds the subtable corresponding to the element .

Excluded determines what values cannot be entered in the cell , for cells that are not yet known.

Four values are excluded for the cell .

OneChoice, applied to the cell , returns the existing value (if any), which is the only choice if eight digits have been excluded, or if the choice is not determined.

There is only one choice for the cell .

Here is the iteration step, Iterate.

And here is the animated solution. You can use the Up and Down Arrow keys to step through the animation once it has started.