template :D
This commit is contained in:
parent
f2c4afd7b4
commit
1f5b785b06
4 changed files with 26 additions and 2 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1 +1,5 @@
|
||||||
inputs/
|
inputs/
|
||||||
|
.session
|
||||||
|
|
||||||
|
*.o
|
||||||
|
*.hi
|
||||||
|
|
|
||||||
7
new.sh
Executable file
7
new.sh
Executable file
|
|
@ -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"
|
||||||
|
|
@ -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))
|
convertToInts = map (\it -> (if head it == 'L' then -1 else 1) * read (drop 1 it))
|
||||||
dropNonZero = filter ((0==) . (`mod` 100))
|
dropNonZero = filter ((0==) . (`mod` 100))
|
||||||
|
|
||||||
|
|
||||||
part2 :: String -> Int
|
part2 :: String -> Int
|
||||||
part2 = length . dropNonZero . scanl (+) 50 . makeSingleSteps . convertToInts . lines
|
part2 = length . dropNonZero . scanl (+) 50 . makeSingleSteps . convertToInts . lines
|
||||||
where
|
where
|
||||||
|
|
@ -16,7 +15,7 @@ part2 = length . dropNonZero . scanl (+) 50 . makeSingleSteps . convertToInts .
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
str <- readFile "inputs/2025-1"
|
str <- getContents
|
||||||
|
|
||||||
print $ part1 str
|
print $ part1 str
|
||||||
print $ part2 str
|
print $ part2 str
|
||||||
|
|
|
||||||
14
template.hs
Normal file
14
template.hs
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue