Last active
January 23, 2019 00:36
-
-
Save ar1a/e9a4a0df7147e50d78041c38ed28526c to your computer and use it in GitHub Desktop.
This file contains 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
aoc1 :: IO () | |
aoc1 = do | |
-- part1 <- sum . getInput <$> getContents | |
part2 <- flip dupSum [] . getInput <$> getContents | |
print part2 | |
pure () | |
dupSum :: [Integer] -> [Integer] -> Integer | |
dupSum (x:xs) sofar = | |
let | |
newSum = sum (x:sofar) | |
in | |
if newSum `elem` sofar then | |
newSum | |
else | |
dupSum xs $ newSum:sofar | |
dupSum [] _ = error "oh no!" -- need to run dupSum initialInputs sofar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment