diff --git a/Day1B.hs b/Day1B.hs index 5c096ef..04db47a 100644 --- a/Day1B.hs +++ b/Day1B.hs @@ -5,9 +5,8 @@ import qualified Data.IntSet as S handle :: Int -> S.IntSet -> [Int] -> Int handle freq history (nextDelta:xs) - | (S.size s) == (S.size history) = freq -- When the frequency is in the history set, return it - | otherwise = handle (freq + nextDelta) (S.insert freq history) xs -- Recurse otherwise - where s = S.insert freq history + | S.member freq history = freq -- When the frequency is in the history set, return it + | otherwise = handle (freq + nextDelta) (S.insert freq history) xs -- Recurse otherwise handle _ _ _ = error "xs should not be empty :(" main :: IO ()