From 8798f1b1e4100c9b53957c6062d4eae285bae2c3 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Fri, 3 Dec 2021 22:18:59 +0100 Subject: [PATCH] Changes --- day3.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/day3.hs b/day3.hs index 2dfa0fb..fb7ef41 100644 --- a/day3.hs +++ b/day3.hs @@ -1023,13 +1023,11 @@ count pos (zero, one) num = case num !! pos of '0' -> (zero + 1, one) '1' -> (zero, one + 1) _ -> (zero, one) -gammaBit (zero, one) - | zero > one = False - | otherwise = True +bitsAt :: Foldable t => t [Char] -> Int -> (Bool, Bool) bitsAt input pos = bits $ foldl (count pos) (0, 0) input - where bits a = (gammaBit a, not $ gammaBit a) + where bits (zero, one) = (zero <= one, zero > one) toNumber :: Foldable t => t Bool -> Int