From: Neil Smith Date: Wed, 4 Dec 2019 08:20:30 +0000 (+0000) Subject: An slightly different way to approach it X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=08852bf6a35168d6cbbf8836ea3e67c01b129034;p=advent-of-code-19.git An slightly different way to approach it --- diff --git a/advent04/src/advent04.hs b/advent04/src/advent04.hs index ac7c175..d7ec1c8 100644 --- a/advent04/src/advent04.hs +++ b/advent04/src/advent04.hs @@ -2,6 +2,7 @@ main :: IO () main = do print part1 + print part1a print part2 lowerLimit = 134792 @@ -9,6 +10,10 @@ upperLimit = 675810 part1 = length $ filter inRange $ filter adjacentSame candidates +part1a = length $ filter (>= lowerLimit) + $ filter (<= upperLimit) + $ map numify + $ filter adjacentSame candidates part2 = length $ filter inRange $ filter isolatedAdjacentSame candidates inRange digits = n >= lowerLimit && n <= upperLimit