Dynamic Web Development with Seaside

Buy PDF Buy Print

16.1Sudoku Solver

For the Sudoku model we use the ML-Sudoku package developed by Martin Laubach which is available on SqueakSource. We thank him for allowing us to use this material. To load the package, open a Monticello browser and click on the +Repository button. Select HTTP as the type of repository and specify it as follows:

location: 'http://www.squeaksource.com/MLSudoku'
user: ''
password: ''

Click on the Open button, select the most recent version and click Load.

ML-Sudoku is composed of 4 classes: MLSudoku, MLBoard, MLCell, and MLPossibilitySet. The class responsibilities are distributed as follows:

  • MLSudoku is the Sudoku solver. It knows how to solve a Sudoku.
  • MLCell knows its neighbors and their location on the game board. A cell does not know its possibility set, see MLPossibilitySet below.
  • MLBoard contains the cells and their possibility sets.
  • MLPossibilitySet is a list of possible numbers between 1 and 9 that can go into a cell. These are the values that are possible without violating the Sudoku rule that each row, column and 3-by-3 sub-grid contains each number once.

Copyright © 23 March 2017 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.