aboutsummaryrefslogtreecommitdiff
path: root/Puzzle1Better.hs
blob: f33d11af7ae9fffda6b7da17a5b7fa3afb084c3f (plain) (blame)
1
2
3
4
5
6
-- source: https://www.reddit.com/r/adventofcode/comments/7gsrc2/2017_day_1_solutions/dqlhkcj/
import Data.Char (digitToInt)

solve n xs = sum $ zipWith (\a b -> if a == b then a else 0) xs (drop n $ cycle xs)
solve1 xs = solve 1 (digitToInt <$> xs)
solve2 xs = solve ((length xs) `div` 2) (digitToInt <$> xs)