From 161f391abae9d1f70f338c7682bdfd1e931d73fc Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sat, 4 Jan 2025 09:38:25 -0500 Subject: [PATCH] Year 2015 Day 1 Part 1 --- src/Years/Y2015/Day1.idr | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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