Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
The Sudoku solver, quintessential SMT solver example!
Synopsis
- type Row = [SWord8]
- type Board = [Row]
- check :: [SWord8] -> SBool
- valid :: Board -> SBool
- type Puzzle = (Int, [SWord8] -> Board)
- sudoku :: Puzzle -> IO ()
- dispSolution :: Puzzle -> (Bool, [Word8]) -> IO ()
- solveAll :: Puzzle -> IO ()
- puzzle0 :: Puzzle
- puzzle1 :: Puzzle
- puzzle2 :: Puzzle
- puzzle3 :: Puzzle
- puzzle4 :: Puzzle
- puzzle5 :: Puzzle
- puzzle6 :: Puzzle
- allPuzzles :: IO ()
Modeling Sudoku
A row is a sequence of 8-bit words, too large indeed for representing 1-9, but does not harm
check :: [SWord8] -> SBool Source #
Given a series of elements, make sure they are all different and they all are numbers between 1 and 9
type Puzzle = (Int, [SWord8] -> Board) Source #
A puzzle is a pair: First is the number of missing elements, second is a function that given that many elements returns the final board.
Solving Sudoku puzzles
dispSolution :: Puzzle -> (Bool, [Word8]) -> IO () Source #
Helper function to display results nicely, not really needed, but helps presentation
Example boards
According to the web, this is the toughest sudoku puzzle ever.. It even has a name: Al Escargot: http://zonkedyak.blogspot.com/2006/11/worlds-hardest-sudoku-puzzle-al.html
The following is nefarious according to http://haskell.org/haskellwiki/Sudoku
allPuzzles :: IO () Source #
Solve them all, this takes a fraction of a second to run for each case