-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.txt
More file actions
40 lines (31 loc) · 2.3 KB
/
report.txt
File metadata and controls
40 lines (31 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
This program has two uses; it can be used to solve a sudoku puzzle or it can be
used to generate a random sudoku puzzle from a seed.
Types.hs defines the types that are used in the program. The board is defined as
an array of cells indexed by a row number and a column number. Each cell can
either be a fixed digit or a set of candidate digits.
Board.hs and Candidate.hs contain code for storing and manipulating the board's
state and helper functions for getting the rows, cols, and boxes.
Main.hs takes in the command-line arguments and calls the requisite functions.
Solver.hs contains the logic for solving a sudoku board. This program uses 6
constraint propagation techniques; in order of complexity: naked single, hidden
single, pointing pairs, box-line reduction, naked-pair, and hidden pair. At each
step, the solver applies the techniques it order of complexity until a valid
move can be made. A move can be either be placing a digit in a cell (like writing a
digit in ) or eliminating a candidate from that cell. The techniques are defined
in the Techniques directory and were implemented following the descriptions in
https://www.sudokuwiki.org/Strategy_Families and https://hodoku.sourceforge.net/en/tech_intro.php.
To run the solver: "cabal run -- --solve" (reads puzzles in from stdin)
Each puzzle must be a single-line string of 81 characters. Use the digits 1-9 for
cells containing clues and either . or 0 for blank cells. Concatenate the characters
together in row-major order.
puzzle.txt contains 5 test puzzles that can be solved by the solver. The first 4
were found on the web and the last one is generated with seed 12.
Generator.hs contains the logic for generating a sudoku puzzle. The generator starts
with a randomized solved puzzle. Then, it shuffles the 81 positions and iterates
through them. At each step, the generator attempts to remove the clue (digit) at
the given position. It checks that the resulting puzzle can be solved using the
same techniques used by the (logic) solver and that the resulting puzzle has
exactly one unique solution. The uniqueness check is done via a backtracking
solver. If the checks fail, the clue is added back. The result is a puzzle that
is guaranteed to have only 1 solution that is solvable by human techniques.
To run the generator: "cabal run -- --generator <seed>"