oops
This commit is contained in:
parent
a68afd169e
commit
2be3c1f086
1 changed files with 2 additions and 3 deletions
3
Day1B.hs
3
Day1B.hs
|
@ -5,9 +5,8 @@ import qualified Data.IntSet as S
|
||||||
|
|
||||||
handle :: Int -> S.IntSet -> [Int] -> Int
|
handle :: Int -> S.IntSet -> [Int] -> Int
|
||||||
handle freq history (nextDelta:xs)
|
handle freq history (nextDelta:xs)
|
||||||
| (S.size s) == (S.size history) = freq -- When the frequency is in the history set, return it
|
| 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
|
| otherwise = handle (freq + nextDelta) (S.insert freq history) xs -- Recurse otherwise
|
||||||
where s = S.insert freq history
|
|
||||||
handle _ _ _ = error "xs should not be empty :("
|
handle _ _ _ = error "xs should not be empty :("
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
|
|
Loading…
Reference in a new issue