Sudoku/app/Main.hs

63 lines
No EOL
1.5 KiB
Haskell

module Main where
import Control.Monad.State (evalState)
import qualified Data.Vector as V
import Types
main :: IO ()
main = do
-- putStrLn $ evalState (insert 5 (2, 5) >> showCandidates3) dummyState
-- print $ evalState (getBoxRange 1) dummyState
-- print $ evalState (getBoxRange 2) dummyState
-- print $ evalState (getBoxRange 3) dummyState
-- print $ evalState (getBoxRange 4) dummyState
-- print $ evalState (getBoxRange 5) dummyState
-- print $ evalState (getBoxRange 6) dummyState
-- print $ evalState (getBoxRange 7) dummyState
-- print $ evalState (getBoxRange 8) dummyState
-- print $ evalState (getBoxRange 9) dummyState
-- print $ evalState (getBox (1, 4)) dummyState
let sudoku = read test :: Sudoku
putStrLn "Reading:"
print sudoku
putStrLn "Pretty Printing:"
putStrLn $ pretty sudoku
putStrLn "Candidates:"
putStrLn $ evalState (insertAll sudoku >> showCandidates3) initState
test :: String
test = "070000043040009610800634900094052000358460020000800530080070091902100005007040802"
{-
070 000 043
040 009 610
800 634 900
094 052 000
358 460 020
000 800 530
080 070 091
902 100 005
007 040 802
-}
dummyState :: SudokuState
dummyState =
SudokuState
{ dimension = 3,
grid = V.replicate 81 0,
idxs = V.fromList [(x, y) | x <- [1 .. 9], y <- [1 .. 9]],
candidates = V.replicate 81 (V.replicate 9 True)
}
initState :: SudokuState
initState =
SudokuState
{ dimension = 0,
grid = V.empty,
idxs = V.empty,
candidates = V.empty
}