module Exercise_7 where import Data.List {-WETT-} trancl :: Eq a => [(Integer,(a,a))] -> [(Integer,(a,a))] trancl xs = if length r == length xs then reduce r else trancl r where r = reach xs xs reduce xs = [x| x <- xs, fst x == minimum (map fst (filter (\y -> snd y == snd x) xs))] reach [] acc = nub acc reach ((i,(a,b)):xs) acc = reach xs ([(i+j,(a,d)) | (j,(c,d)) <- acc, b==c, length (filter (\(m,n) -> n==(a,d) && m < i+j) acc) <= 0]++acc) {-TTEW-}