Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-04 10:54:52 +05:30
parent cab03d0a2f
commit 90bf32db20
2 changed files with 1029 additions and 0 deletions

29
day4.hs Normal file
View File

@@ -0,0 +1,29 @@
import Lib (split)
main :: IO ()
main = do
input <- readFile "day4.in"
putStr "Q1: "
print $ q1 input
putStr "Q2: "
print $ q2 input
q1 :: String -> Int
q1 =
length
. filter
( \x ->
let [[a, b], [c, d]] = map (map (read :: String -> Int) . split '-') $ split ',' x
in a >= c && b <= d || c >= a && d <= b
)
. lines
q2 :: String -> Int
q2 =
length
. filter
( \x ->
let [[a, b], [c, d]] = map (map (read :: String -> Int) . split '-') $ split ',' x
in b >= c && a <= d || d >= a && c <= b
)
. lines

1000
day4.in Normal file

File diff suppressed because it is too large Load Diff