- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
import Control.Monad
import Control.Arrow
import Data.List
solve' :: [String] -> [[String]]
solve' = nub . filter (
and . uncurry (
zipWith (
(.head) . (==) . last
)
) . (id &&& tail)
) . uncurry ($) . (
last . (((
map (
last . fst &&& uncurry (++) . (init . fst &&& snd)
) . tail . uncurry (zipWith (,)) . (inits &&& tails)
) >=> (uncurry map) .
((:) *** solve')
):
) . (uncurry takeWhile) . (
const . null &&& const [const [[]]]
) &&& id
)
main = print $ solve' ["123","321","123"]