Sudoku Validator is a command line java application that validates a sudoku which is given in a csv (.csv or .txt) file. In case of a valid Sudoku the validator returns 0 and non-zero for an invalid one.
A given Sudoku is valid if all of the following rules are fulfilled.
- Each row must contain the digits 1-9 without repetition
- Each column must contain the digits 1-9 without repetition.
- Each of the 9 3x3 sub-boxes of the grid must contain the digits 1-9 without repetition.
- The Sudoku board could be partially filled, where empty cells can be filled with an empty character (space) (or no-character).
, , ,9,1,7, , ,8
, ,5, , ,4, , ,2
, , , , , ,4,9,
6,5, ,3, ,1, ,2,4
1,4, ,8, ,9, ,6,3
8,3, ,4, ,5, ,1,9
,7,8, , , , , ,
4, , ,5, , ,6, ,
5, , ,7,4,8, , ,
9, , ,9,1,7, , ,8
, ,5, , ,4, , ,2
, , , , , ,4,9,
6,5, ,3, ,1, ,2,4
1,4, ,8, ,9, ,6,3
8,3, ,4, ,5, ,1,9
,7,8, , , , , ,
4, , ,5, , ,6, ,
5, , ,7,4,8, , ,
Directory | Description |
---|---|
./run | Run script (validateSudoku.bat) |
./src | The source code. |
Sudoku Validator is a maven project and can be compiled by running the following:
mvn clean compile
Sudoku Validator is a maven project and can be built by running the following:
mvn clean package
By building the project we can find an executable jar file in ./target/sudoku-validator-***-.jar
as well as the required libraries in ./target/libs/
.
Sudoku validator can be ran in Windows OS by running from the run dir the following:
validateSudoku.bat givenSudoku.txt
In order to generate the test-coverage report you can run the following:
mvn clean test
The generated reports can be found in ./target/site/jacoco/index.html
.
eg.
It is out of scope the check if a given sudoku is solvable or not. Solvable means that the given sudoku has one and only one solution.