Adapted description and extended testdata
This commit is contained in:
parent
f5aa725b72
commit
8ca4a5e0a5
26
README.md
26
README.md
@ -1,21 +1,31 @@
|
|||||||
# Sudoku verifier
|
# Validate a Sudoku
|
||||||
|
|
||||||
## Definition
|
## Definition
|
||||||
Sudokus are logic number puzzles in which cells in a 9×9 grid must be populated with
|
Sudokus are number-puzzles in which cells in a 9×9 grid must be populated with the numbers `1` to `9`.
|
||||||
the digits 1 to 9 in a way that each digit occurrs only once in each unit (that is column,
|
|
||||||
row or block = 3×3 sub grid).
|
The following constraints must apply to the 9×9 grid.
|
||||||
|
|
||||||
|
* Each digit from `1` to `9` only occurs only once
|
||||||
|
* per row
|
||||||
|
* per column
|
||||||
|
* per block (i.e. 3×3 sub grid)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Goal
|
## Goal
|
||||||
Validate if a given solution for a Sudoku is valid, by checking that the digit
|
Validate, if a given Sudoku is a valid solution.
|
||||||
1 to 9 appear only once in column, in each row and in each of the 9 sub grids.
|
|
||||||
|
The Sudoku must comply with the definition above.
|
||||||
|
|
||||||
### Input
|
### Input
|
||||||
a sequence of 81 digits, organized in 9 columns and 9 rows
|
A sequence of 81 digits, organized in 9 columns and 9 rows.
|
||||||
|
|
||||||
|
The columns of a row are separated by blanks.
|
||||||
|
|
||||||
|
Rows are separated by line-breaks.
|
||||||
|
|
||||||
### Output
|
### Output
|
||||||
A boolean value, if the grid is valid.
|
A boolean value `true` or `false` defining the correctness of the input.
|
||||||
|
|
||||||
### Constraints
|
### Constraints
|
||||||
1 <= `digit` <= 9
|
1 <= `digit` <= 9
|
||||||
|
9
src/test/resources/sudoku6.txt
Normal file
9
src/test/resources/sudoku6.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
1 7 2 5 4 9 6 8 3
|
||||||
|
6 4 5 8 7 3 2 1 9
|
||||||
|
3 8 9 2 6 1 7 4 5
|
||||||
|
4 9 6 3 2 7 8 5 1
|
||||||
|
8 1 3 4 5 6 9 7 2
|
||||||
|
2 5 7 1 9 8 4 3 6
|
||||||
|
9 6 4 7 1 5 3 2 8
|
||||||
|
7 3 1 6 8 2 5 9 4
|
||||||
|
5 2 8 9 3 4 1 6 7
|
9
src/test/resources/sudoku7.txt
Normal file
9
src/test/resources/sudoku7.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
9 5 7 6 1 3 2 8 4
|
||||||
|
4 8 3 2 5 7 1 9 6
|
||||||
|
6 1 2 8 4 9 5 3 7
|
||||||
|
1 7 8 3 6 4 9 5 2
|
||||||
|
5 2 4 9 7 1 3 6 8
|
||||||
|
3 6 9 5 2 8 7 4 1
|
||||||
|
8 4 5 7 9 2 6 1 3
|
||||||
|
2 9 1 4 3 6 8 7 5
|
||||||
|
7 3 6 1 8 5 4 2 9
|
9
src/test/resources/sudoku8.txt
Normal file
9
src/test/resources/sudoku8.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
1 7 2 5 4 9 6 8 3
|
||||||
|
6 4 5 8 7 3 2 1 9
|
||||||
|
3 8 9 2 6 1 7 4 5
|
||||||
|
4 9 6 3 2 7 8 5 1
|
||||||
|
8 1 3 4 5 6 9 7 2
|
||||||
|
2 5 7 1 9 8 4 3 6
|
||||||
|
9 6 4 7 2 5 3 2 8
|
||||||
|
7 3 1 6 8 2 5 9 4
|
||||||
|
5 2 8 9 3 4 1 6 7
|
@ -3,3 +3,6 @@ sudoku2.txt, true
|
|||||||
sudoku3.txt, false
|
sudoku3.txt, false
|
||||||
sudoku4.txt, true
|
sudoku4.txt, true
|
||||||
sudoku5.txt, false
|
sudoku5.txt, false
|
||||||
|
sudoku6.txt, true
|
||||||
|
sudoku7.txt, true
|
||||||
|
sudoku8.txt, false
|
|
Loading…
x
Reference in New Issue
Block a user