projects
/
advent-of-code-20.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tidying, and adding problems
[advent-of-code-20.git]
/
advent05
/
src
/
advent05.hs
diff --git
a/advent05/src/advent05.hs
b/advent05/src/advent05.hs
index 06d0ecca35976face9225eabf73f695e236d55b9..40a72a169388660b26f9805b35661bdec732795f 100644
(file)
--- a/
advent05/src/advent05.hs
+++ b/
advent05/src/advent05.hs
@@
-1,7
+1,7
@@
-- import Debug.Trace
import Numeric
-- import Debug.Trace
import Numeric
-import
qualified Data.Set as S
+import
Data.List
main :: IO ()
main =
main :: IO ()
main =
@@
-12,12
+12,11
@@
main =
part1 = maximum . map convert
part1 = maximum . map convert
-part2 passes =
S.elemAt 0 $ expecteds `S.difference` know
ns
+part2 passes =
head $ expecteds \\
ns
where ns = map convert passes
highest = maximum ns
lowest = minimum ns
where ns = map convert passes
highest = maximum ns
lowest = minimum ns
- knowns = S.fromList ns
- expecteds = S.fromList [lowest..highest]
+ expecteds = [lowest..highest]
directionToInt :: Char -> Int
directionToInt dir = if dir `elem` "BR" then 1 else 0
directionToInt :: Char -> Int
directionToInt dir = if dir `elem` "BR" then 1 else 0