2024-03-21 13:56:57 +01:00
|
|
|
module Main where
|
|
|
|
|
2024-03-21 17:27:24 +01:00
|
|
|
import Control.Monad.State (evalState)
|
|
|
|
import qualified Data.Vector as V
|
2024-03-21 13:56:57 +01:00
|
|
|
import Types
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2024-03-21 17:27:24 +01:00
|
|
|
-- 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
|
|
|
|
|
2024-03-21 13:56:57 +01:00
|
|
|
putStrLn "Reading:"
|
2024-03-21 17:27:24 +01:00
|
|
|
print sudoku
|
2024-03-21 13:56:57 +01:00
|
|
|
putStrLn "Pretty Printing:"
|
2024-03-21 17:27:24 +01:00
|
|
|
putStrLn $ pretty sudoku
|
|
|
|
|
|
|
|
putStrLn "Candidates:"
|
|
|
|
putStrLn $ evalState (insertAll sudoku >> showCandidates3) initState
|
2024-03-21 13:56:57 +01:00
|
|
|
|
|
|
|
test :: String
|
2024-03-21 17:27:24 +01:00
|
|
|
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
|
|
|
|
}
|