Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- parts2 [] = False
- parts2 (x:xs) = (mod (length (x:xs)) 2 == 0) && (parts2' [x] [] xs)
- where
- n = div (length (x:xs)) 2
- parts2' xs ys [] = length xs == n
- parts2' (x:xs) [] (z:zs) = (try (x:xs) (z:zs)) || parts2' (x:xs) [z] zs
- where
- try (x:xs) (z:zs)
- | length (x:xs) == n = False
- | z > x = parts2' (z:x:xs) [] zs
- | otherwise = False
- parts2' (x:xs) (y:ys) (z:zs) = (try1 (x:xs) (y:ys) (z:zs)) || (try2 (x:xs) (y:ys) (z:zs))
- where
- try1 (x:xs) (y:ys) (z:zs)
- | length (x:xs) == n = False
- | z > x = parts2' (z:x:xs) (y:ys) zs
- | otherwise = False
- try2 (x:xs) (y:ys) (z:zs)
- | length (y:ys) == n = False
- | z > y = parts2' (x:xs) (z:y:ys) zs
- | otherwise = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement