From f2b6275f15507ea8adb12455dfab9f59ab9b5929 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Tue, 12 Dec 2023 22:37:55 -0800 Subject: [PATCH] inline --- solutions/src/2023/13.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/solutions/src/2023/13.hs b/solutions/src/2023/13.hs index b7838a9..65d14ba 100644 --- a/solutions/src/2023/13.hs +++ b/solutions/src/2023/13.hs @@ -51,12 +51,11 @@ findReflection target xs = [ i | (i,l,r) <- zip3 [0..] (inits xs) (tails xs) , not (null l), not (null r) - , target == sum (zipWith (\x y -> sum (zipWith val x y)) (reverse l) r) + , let val x y = if x == y then 0 else 1 + , let differences x y = sum (zipWith val x y) + , target == sum (zipWith differences (reverse l) r) ] solver :: Int -> [String] -> [Int] solver target xs = findReflection target (transpose xs) ++ map (100*) (findReflection target xs) - -val :: Char -> Char -> Int -val x y = if x == y then 0 else 1