-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Exercise 2. Good but refactoring can be more complete.
In many more places it is possible to replace Constraints by [Position]
type Node = (Sudoku,[Position])
prune :: (Row,Column,Value)
-> [Position] -> [Position]
constraints :: Sudoku -> [Position]
Why not using
eraseN :: Node -> (Row,Column) -> Node
eraseN n (r,c) = (s, constraints s)
and
Ex. 3
minimal :: Grid -> Bool
minimal g = solutionCount g == 1
&& all (\x -> solutionCount x > 1) (smallerProblems g)
Why not using
eraseN :: Node -> (Row,Column) -> Node
eraseN n (r,c) = (s, constraints s)
and
uniqueSol :: Node -> Bool
uniqueSol node = singleton (solveNs [node]) where
singleton [] = False
singleton [x] = True
singleton (x:y:zs) = False
Exercise 4
doExercise4 :: IO()
doExercise4 = do [r] <- rsolveNs [emptyN]
showNode r
s <- genProblemEmptyBlocks 20 r
print$uniqueSol s // There are cases that s doesn't have an unique solution
showNode s
Metadata
Metadata
Assignees
Labels
No labels