In this project, you will create an interface for users to play sudoku. Note that you will NOT be generating the puzzle itself. You will develop an interface for the user to play the puzzle and verify if the user successfully completed the puzzle. If you are not familiar with the game of sudoko, read about it here. The game is really simple, but make sure you know the rules. (try a few easy ones yourself if you are unfamiliar with it)
Figure below shows a sample puzzle that users of your program will try to solve. The letters a, b, c etc on the rows and columns are used to identify a specific cell in the puzzle. For example, in the figure below, (a, b) = 2, (b, e) = 8, (g, b) = 7 and so on. The order is (row, column).
Interacting with the user
When the program is run the first time, you should print the initial puzzle in the console as shown below. Underscore (_) denotes empty cells and the pipe(|) key separates two neighboring cells.
The game says 'Puzzle Incomplete!' and prompts the user to enter a new value. User can enter value for a new cell by specifying rowid columnid and value, each separated by a blank-space. In the run above, the user entered b a 9, which results in the program printing the second version of the puzzle with cell (b a) filled with value 9. Then user enters b b 3, and so on.
No need to check for invalid input. (eg: k b 10)
Users CANNOT overwrite the locked cells(The cells automatically filled when game is initialized). If user tries to change a locked cell, print “Fixed location. Cannot change value!” (See image below)
Users CAN overwrite editable or free cells any number of times.
The program just keeps displaying 'Puzzle Incomplete!' until the user gets it right.
If user enters duplicate values in the same row/col, allow it, but game should remain incomplete.
User will always enter a char between a - i and value between 1 - 9.
The initial puzzle will have at least one empty cell.
There will always be one unique solution.
This cycle is repeated until the puzzle is solved.
Checking for puzzle completion
Every time user enters a new value, you need to check if the puzzle is complete. The puzzle gets completed when the 9×9 grid is completely full, with each column, each row, and each of the nine 3×3 sub-grids contains all of the digits from 1 to 9. In other words, a puzzle is considered complete when,
Within one row no digits are repeated.
Within one column no digits are repeated.
Within one 3×3 region no digits are repeated.
There are no empty cells.
Only the digits from 1 to 9 are used (both inclusive).
When the user completes the game, print 'Puzzle Complete!' and exit the game.
Creating the Puzzle
You can assume the puzzle to be a 9×9 grid of 2-D integer array. The source files you downloaded contains [url removed, login to view] which defines this 2-D array. In this array, a value of (-1) indicates an empty cell. All other non-negative values denotes the initial, locked cells in the puzzle. Again, user is not allowed to change any of these locked cells.
Note that you should not add any additional variables or methods into this file - Constants.java. This file will be replaced for grading. IMPORTANT: Your program should work for any 9 x 9 sudoku puzzle that is represented by the 2-D game array in Constants.java.