Adds solution 2
parent
9d534067ab
commit
64dedab06a
|
@ -0,0 +1,13 @@
|
|||
module Main where
|
||||
|
||||
import Data.List (group, sort)
|
||||
|
||||
main = do
|
||||
ids <- lines <$> getContents
|
||||
print (length (repeatCounts 2 ids) * length (repeatCounts 3 ids))
|
||||
|
||||
let (a, b) = head [(x, y) | x <- ids, y <- ids, countDiffChars x y == 1]
|
||||
print $ filter (/= '!') $ zipWith (\x y -> if x == y then x else '!') a b
|
||||
where
|
||||
repeatCounts x = filter (x `elem`) . map (map length . group . sort)
|
||||
countDiffChars as bs = sum $ zipWith (\a b -> if a == b then 0 else 1) as bs
|
Loading…
Reference in New Issue