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 #6

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

Lab 5 #6

BertLisser opened this issue Oct 12, 2018 · 0 comments

Comments

@BertLisser
Copy link

Ex 2
The following is okay

constraints :: Sudoku -> [Constraint]
constraints s = sortBy length3rd
    [(r,c, freeAtPositions s (r,c)) |
                       (r,c) <- openPositions s ]

but why not simplify

-- A slightly modified version of the example prune code.
prune :: (Row,Column,Value)
      -> [Constraint] -> Bool -> [Constraint]
prune _ [] isNRC = []
prune (r,c,v) ((x,y,zs):rest) isNRC
  | r == x = (x,y,zs\\[v]) : prune (r,c,v) rest isNRC
  | c == y = (x,y,zs\\[v]) : prune (r,c,v) rest isNRC
  | sameBlock (r,c) (x,y) =
        (x,y,zs\\[v]) : prune (r,c,v) rest isNRC
  | isNRC && nrcSameBlock (r,c) (x,y) =
      (x,y,zs\\[v]) : prune (r,c,v) rest isNRC
  | otherwise = (x,y,zs) : prune (r,c,v) rest isNRC

?
I see you understand this, but you are on the half way.

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