Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab 5 #4

Open
BertLisser opened this issue Oct 12, 2018 · 0 comments
Open

Lab 5 #4

BertLisser opened this issue Oct 12, 2018 · 0 comments

Comments

@BertLisser
Copy link

BertLisser commented Oct 12, 2018

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant