Day 02 - (\) deletes the first occurrence, so back to using zip + filter.
This commit is contained in:
parent
ff27252c39
commit
b07bc495bb
|
@ -7,7 +7,8 @@ part1 strs = (length . filter (count 2) $ strs) * (length . filter (count 3) $ s
|
|||
where count n = any (== n) . map length . group . sort
|
||||
|
||||
part2 :: [String] -> String
|
||||
part2 strs = head [ls `intersect` rs | ls <- strs, rs <- strs, length (ls \\ rs) == 1]
|
||||
part2 strs = head [xs `intersect` ys | xs <- strs, ys <- strs, dist xs ys == 1]
|
||||
where dist = (length .) . (filter id .) . zipWith (/=)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
|
|
Loading…
Reference in New Issue