projects
/
advent-of-code-18.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
09aa30f
)
Part 2 point-free
author
Neil Smith
<neil.git@njae.me.uk>
Sat, 1 Dec 2018 13:42:26 +0000
(13:42 +0000)
committer
Neil Smith
<neil.git@njae.me.uk>
Sat, 1 Dec 2018 13:42:26 +0000
(13:42 +0000)
src/advent01/advent01.hs
patch
|
blob
|
history
diff --git
a/src/advent01/advent01.hs
b/src/advent01/advent01.hs
index d833bbcc96814d40be8b7094383e40c067837397..e1935f475587e9f1ee771303b31d4e1d659e5681 100644
(file)
--- a/
src/advent01/advent01.hs
+++ b/
src/advent01/advent01.hs
@@
-26,7
+26,7
@@
part1 :: [Int] -> Int
part1 = sum
part2 :: [Int] -> Int
-part2
changes = snd $ head $ dropWhile unRepeated $ scanl merge (S.empty, 0) $ cycle changes
+part2
= snd . head . dropWhile unRepeated . scanl merge (S.empty, 0) . cycle
merge :: (IntSet, Int) -> Int -> (IntSet, Int)
merge (frequencies, frequency) change = (S.insert frequency frequencies, frequency + change)