module Exercise_7 where import Data.List import Data.Maybe import Control.Monad {-WETT-} trancl xs = if null xs'' then nub $ filter (isMin xs) xs else trancl (xs++xs'') where xs' = fmap not (`elem` xs) `filter` [(x1 + y1,(fst x2, snd y2)) | (x1,x2) <- xs, (y1,y2) <- xs, snd x2 == fst y2] xs'' = nub $ filter (isMin xs) xs' isMin xs (a,b) = isNothing $ find (\(a',b') -> b == b' && a' < a) xs {-TTEW-} {-MCCOMMENT - This is (according to my checks) technically correct, but has terrible runtime - and space-complexity. It does use less tokens tho, so I'm including it. - To be completely honest, I had next to no time for the competition this week - and I am kinda hoping that neither solutions are competetive. - (Also I had atleast some fun with comp trying to use liftM2 or some Applicatives - but that turned out to be worse token-wise :D) trancl xs = nub $ min $ comp $ concat $ take (2* length xs) $ iterate comp xs where comp xs = [(x1 + y1,(fst x2, snd y2)) | (x1,x2) <- xs, (y1,y2) <- xs, snd x2 == fst y2] min xs = filter (\(a,b) -> isNothing $ find (\(a',b') -> b == b' && a' < a) xs) xs -}