-part2 ids = uncurry sameChars closeIds
- where closeIds = head $ filter (\ab -> uncurry differenceCount ab == 1) [(a, b) | a <- ids, b <- ids]
+part2 ids = uncurry intersect closeIds
+ where closeIds = head $ filter (\ab -> uncurry differenceCount ab == 1)
+ [(a, b) | a:rest <- tails ids, b <- rest]