org.apache.hadoop.examples.dancing
Class Sudoku

java.lang.Object
  extended by org.apache.hadoop.examples.dancing.Sudoku

public class Sudoku
extends Object

This class uses the dancing links algorithm from Knuth to solve sudoku puzzles. It has solved 42x42 puzzles in 1.02 seconds.


Nested Class Summary
protected static interface Sudoku.ColumnName
          This interface is a marker class for the columns created for the Sudoku solver.
 
Constructor Summary
Sudoku(InputStream stream)
          Set up a puzzle board to the given size.
 
Method Summary
static void main(String[] args)
          Solves a set of sudoku puzzles.
 void solve()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sudoku

public Sudoku(InputStream stream)
       throws IOException
Set up a puzzle board to the given size. Boards may be asymmetric, but the squares will always be divided to be more cells wide than they are tall. For example, a 6x6 puzzle will make sub-squares that are 3x2 (3 cells wide, 2 cells tall). Clearly that means the board is made up of 2x3 sub-squares.

Parameters:
stream - The input stream to read the data from
Throws:
IOException
Method Detail

solve

public void solve()

main

public static void main(String[] args)
                 throws IOException
Solves a set of sudoku puzzles.

Parameters:
args - a list of puzzle filenames to solve
Throws:
IOException


Copyright © 2009 The Apache Software Foundation