--- /dev/null
+main = do
+ contents <- getContents
+ print . sum $ map toInt (lines contents)
+
+toInt :: String -> Int
+toInt (x:xs) = if x == '+'
+ then read xs :: Int
+ else -(read xs :: Int)
--- /dev/null
+import qualified Data.Set as S
+
+main = do
+ contents <- getContents
+ let freqs = cycle $ map toInt (lines contents)
+ print $ findDouble (S.empty :: S.Set Int) 0 freqs
+
+toInt :: String -> Int
+toInt (x:xs) = if x == '+'
+ then read xs :: Int
+ else -(read xs :: Int)
+
+findDouble :: S.Set Int -> Int -> [Int] -> Int
+findDouble history total (x:xs)
+ | S.member total history = total
+ | otherwise = findDouble nextHist nextTotal xs
+ where nextHist = S.insert total history
+ nextTotal = total + x