diff --git a/src/Years/Y2015/Day1.idr b/src/Years/Y2015/Day1.idr index cbe81d0..09db409 100644 --- a/src/Years/Y2015/Day1.idr +++ b/src/Years/Y2015/Day1.idr @@ -4,7 +4,19 @@ import Control.Eff import Runner -part1 : Eff (PartEff String) ((), ()) +%default total + +trackFloor : (start : Integer) -> (xs : List Char) -> Integer +trackFloor start [] = start +trackFloor start ('(' :: xs) = trackFloor (start + 1) xs +trackFloor start (')' :: xs) = trackFloor (start - 1) xs +trackFloor start (x :: xs) = trackFloor start xs + +part1 : Eff (PartEff String) (Integer, ()) +part1 = do + input <- map unpack $ askAt "input" + let output = trackFloor 0 input + pure (output, ()) export day1 : Day