Advertisement
Albinutte

4.3

Sep 19th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. parts2 [] = False
  2.  
  3. parts2 (x:xs) = (mod (length (x:xs)) 2 == 0) && (parts2' [x] [] xs)
  4. where
  5. n = div (length (x:xs)) 2
  6. parts2' xs ys [] = length xs == n
  7. parts2' (x:xs) [] (z:zs) = (try (x:xs) (z:zs)) || parts2' (x:xs) [z] zs
  8. where
  9. try (x:xs) (z:zs)
  10. | length (x:xs) == n = False
  11. | z > x = parts2' (z:x:xs) [] zs
  12. | otherwise = False
  13. parts2' (x:xs) (y:ys) (z:zs) = (try1 (x:xs) (y:ys) (z:zs)) || (try2 (x:xs) (y:ys) (z:zs))
  14. where
  15. try1 (x:xs) (y:ys) (z:zs)
  16. | length (x:xs) == n = False
  17. | z > x = parts2' (z:x:xs) (y:ys) zs
  18. | otherwise = False
  19. try2 (x:xs) (y:ys) (z:zs)
  20. | length (y:ys) == n = False
  21. | z > y = parts2' (x:xs) (z:y:ys) zs
  22. | otherwise = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement