diff --git a/2/2.hs b/2/2.hs new file mode 100644 index 0000000..aa16fe7 --- /dev/null +++ b/2/2.hs @@ -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 \ No newline at end of file