From 1f5b785b06042de1c0001f1b8c166a01dcd59654 Mon Sep 17 00:00:00 2001 From: KoenDR06 Date: Mon, 1 Dec 2025 13:44:35 +0100 Subject: [PATCH] template :D --- .gitignore | 4 ++++ new.sh | 7 +++++++ src/Day2501.hs | 3 +-- template.hs | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 new.sh create mode 100644 template.hs diff --git a/.gitignore b/.gitignore index 6b9a1e9..c469b64 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ inputs/ +.session + +*.o +*.hi diff --git a/new.sh b/new.sh new file mode 100755 index 0000000..c3e22e0 --- /dev/null +++ b/new.sh @@ -0,0 +1,7 @@ +curl https://adventofcode.com/$1/day/$2/input --cookie session=$(cat .session) > inputs/$1-$2 + +day=$(echo $1 | sed 's/..//') +year=$(printf %02d $2) +cp -n template.hs src/Day${day}${year}.hs + +alias run="ghc src/Day${day}${year}.hs -o out && cat inputs/$1-$2 | ./out && hyperfine --input inputs/$1-$2 -N --warmup 10 --runs 10 \"./out\" && rm out" diff --git a/src/Day2501.hs b/src/Day2501.hs index debf70b..3ffb7b6 100644 --- a/src/Day2501.hs +++ b/src/Day2501.hs @@ -6,7 +6,6 @@ part1 = length . dropNonZero . scanl (+) 50 . convertToInts . lines 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 @@ -16,7 +15,7 @@ part2 = length . dropNonZero . scanl (+) 50 . makeSingleSteps . convertToInts . main :: IO () main = do - str <- readFile "inputs/2025-1" + str <- getContents print $ part1 str print $ part2 str diff --git a/template.hs b/template.hs new file mode 100644 index 0000000..0f65d1d --- /dev/null +++ b/template.hs @@ -0,0 +1,14 @@ +module Main where + +part1 :: String -> Int +part1 = undefined + +part2 :: String -> Int +part2 = undefined + +main :: IO () +main = do + str <- getContents + + print $ part1 str + print $ part2 str