LINUX.ORG.RU

История изменений

Исправление Waterlaz, (текущая версия) :

solve (a, b) xs = (a, b) : (concat $ map (sub (b+1, a-1)) xs)
    where sub (c, d) (a, b) =
            filter (\(a, b) -> a<=b) 
                   [(min a c, min b d), (max a c, max b d)]
*Main> solve (1, 4)  [(5, 8)]
[(1,4),(5,8)]

*Main> solve (1, 6) [(5, 8)]
[(1,6),(7,8)]

*Main> solve (6, 9) [(5, 8)]
[(6,9),(5,5)]

*Main> solve (5, 6) [(1, 9)] 
[(5,6),(1,4),(7,9)]

*Main> solve (1, 9)  [(5, 6)]
[(1,9)]

*Main> solve (3, 8) [(1, 4), (5, 6), (7, 10)] 
[(3,8),(1,2),(9,10)]

Где мои деньги?

Исходная версия Waterlaz, :

solve (a, b) xs = (a, b) : (concat $ map (sub (b+1, a-1)) xs)
    where
        sub (c, d) (a, b) =
            filter (\(a, b) -> a<=b) 
                   [(min a c, min b d), (max a c, max b d)]
*Main> solve (1, 4)  [(5, 8)]
[(1,4),(5,8)]

*Main> solve (1, 6) [(5, 8)]
[(1,6),(7,8)]

*Main> solve (6, 9) [(5, 8)]
[(6,9),(5,5)]

*Main> solve (5, 6) [(1, 9)] 
[(5,6),(1,4),(7,9)]

*Main> solve (1, 9)  [(5, 6)]
[(1,9)]

*Main> solve (3, 8) [(1, 4), (5, 6), (7, 10)] 
[(3,8),(1,2),(9,10)]

Где мои деньги?