Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2024-12-25 15:05:13 +05:30
parent d866d5ea3a
commit 317668fc5d
2 changed files with 38 additions and 0 deletions

View File

@@ -184,3 +184,8 @@ executable day24
build-depends: build-depends:
, containers , containers
, libaoc , libaoc
executable day25
import: common
hs-source-dirs: src
main-is: Day25.hs

33
src/Day25.hs Normal file
View File

@@ -0,0 +1,33 @@
module Main where
import Data.List (partition)
group :: [[a]] -> [[[a]]]
group [] = []
group ([] : xs) = group xs
group xs = take 7 xs : group (drop 7 xs)
part1 :: [[String]] -> [[String]] -> Int
part1 locks keys =
length
[ ()
| lock <- locks,
key <- keys,
and
[ l == '.' || k == '.'
| (lrow, krow) <- zip lock key,
(l, k) <- zip lrow krow
]
]
main :: IO ()
main =
do
(locks, keys) <-
partition ((== '#') . head . head)
. group
. lines
<$> readFile "./inputs/day25.in"
putStr "Part 1: " >> print (part1 locks keys)
putStrLn "Part 2: See you next year :D"