From 5335839f73aa27c48bfee94ed066bc531356d826 Mon Sep 17 00:00:00 2001 From: shu Date: Thu, 3 Dec 2020 06:46:38 +0100 Subject: [PATCH] Day 3: be a bit less retarded --- 2020/day03/day03.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2020/day03/day03.hs b/2020/day03/day03.hs index 38ba0f9..61d7271 100644 --- a/2020/day03/day03.hs +++ b/2020/day03/day03.hs @@ -1,16 +1,16 @@ main :: IO () main = do input <- map (concat . repeat) . lines <$> readFile "input" - print $ day3 input ((3,1),0) - let slopes = [((1,1),0),((3,1),0),((5,1),0),((7,1),0),((1,2),0)] + print $ day3 input ((3,1)) + let slopes = [(1,1),(3,1),(5,1),(7,1),(1,2)] print $ product $ map (day3 input) slopes type Slope = ((Int, Int), Int) -day3 :: [String] -> Slope -> Int +day3 :: [String] -> (Int,Int) -> Int day3 input slope = a where - (_, a) = day3rec (input, 0) slope + (_, a) = day3rec (input, 0) (slope,0) day3rec :: ([String], Int) -> Slope -> ([String], Int) day3rec (t:ts, acc) ((x, y), l) =