X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent05.hs;h=c86b14c97b5130f4fc3d7630f5ebe7db4ba06aea;hb=e1edd01d136082aa14fbd9b53c12344efc447466;hp=d86bd5aee32ee5301f82a3dc099b2e4eafcc604d;hpb=fef438e522205404e0e765414e412ccacc34bfaa;p=advent-of-code-16.git diff --git a/advent05.hs b/advent05.hs index d86bd5a..c86b14c 100644 --- a/advent05.hs +++ b/advent05.hs @@ -38,7 +38,7 @@ dontReplace :: (Integer, Char) -> Password -> Password dontReplace (k, v) = Map.insertWith (\_ v -> v) k v findPassword :: Password -> [(Integer, Char)] -> Password -findPassword p (candidate:candidates) +findPassword p (c:cs) | Map.size p == 8 = p - | otherwise = findPassword p' candidates - where p' = dontReplace candidate p + | otherwise = findPassword p' cs + where p' = dontReplace c p