Last active
February 27, 2016 09:43
-
-
Save BartG95/ebf9fcc9e813b125f8a1 to your computer and use it in GitHub Desktop.
7 languages, Haskell, day 1, map-coloring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Author: Bart Groeneveld | |
-- License: GPLv3 | |
module Main where | |
data Color = Red | |
| Green | |
| Blue | |
deriving (Eq, Show, Enum) | |
colors = [Red ..] | |
coloring = head [[("Tennessee" , cr1), | |
("Mississippi", cr2), | |
("Alabama" , cr3), | |
("Georgia" , cr4), | |
("Florida" , cr5)] | |
| cr1 <- colors, | |
cr2 <- colors, | |
cr3 <- colors, | |
cr4 <- colors, | |
cr5 <- colors, | |
cr1 `notElem` [cr2, cr3, cr4], | |
cr3 `notElem` [cr2, cr4], | |
cr5 `notElem` [cr2, cr3, cr4]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One more thing: Try to solve it in parts. You currently are trying to solve it in one big function, which makes it harder to reason about it IMO. Clearly c2 and c4 have no restrictions, thus you can extract those.