commit f2c4afd7b49dc85694d32d080b60a7164027df82 Author: KoenDR06 Date: Mon Dec 1 11:18:02 2025 +0100 init + day 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b9a1e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +inputs/ diff --git a/src/Day2501.hs b/src/Day2501.hs new file mode 100644 index 0000000..debf70b --- /dev/null +++ b/src/Day2501.hs @@ -0,0 +1,22 @@ +module Main where + +part1 :: String -> Int +part1 = length . dropNonZero . scanl (+) 50 . convertToInts . lines + where + convertToInts = map (\it -> (if head it == 'L' then -1 else 1) * read (drop 1 it)) + dropNonZero = filter ((0==) . (`mod` 100)) + + +part2 :: String -> Int +part2 = length . dropNonZero . scanl (+) 50 . makeSingleSteps . convertToInts . lines + where + convertToInts = map (\it -> (if head it == 'L' then -1 else 1) * read (drop 1 it)) + dropNonZero = filter ((0==) . (`mod` 100)) + makeSingleSteps = concatMap (\it -> replicate (abs it) (signum it)) + +main :: IO () +main = do + str <- readFile "inputs/2025-1" + + print $ part1 str + print $ part2 str