CSC220 Lab 6
Due: 10:59AM, Tuesday, October 19

Your task is to write a code for solving Sudoku puzzles.

A Sudoku diagram is a 9 by 9 grid of numbers between 1 and 9 such that

An input to Sudoku is a 9 by 9 grid with numbers hidden at some locations and its solution is a complete Sudoku grid that is constructed by assigning numbers to the locations with numbers hidden.

Here are some specifics about how this problem should be solved.

Two sample solutions are presented here: a slow solution and a fast solution. The slow solution checks whether a number can be assigned to a location using the aforementioned three rules and avoid trying to set an impossible number, so as to reduce the number of recursive calls. The fast solution adds more rules to the three and tries to find a location for which the assingment is uniquely determined.

In both solution, a two-dimensional array of buttons is used to represent the contents of the 9 by 9 grid. The class file for that is Grid.java. To show the grid on the screen you have to do:

  1. JFrame frame = new JFrame();
  2. Grid grid = new Grid(9,9);
  3. frame.add(grid);
  4. frame.pack();
  5. frame.setVisible(true);
The contents of the grid can be set via the following methods:
  1. setDefaultColor(int i, int j): set the color of location (i,j) to green;
  2. setAlternativeColor(int i, int j): set the color of location (i,j) to blue;
  3. setOneText(int i, int j, String text): set the text shown at location (i,j) to text;