Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Given an array of integers greater than zero, find if it is possible to
- split it in two (without reordering the elements), such that the sum
- of the two resulting arrays is the same. Print the resulting arrays.
- */
- /*
- # In [1]: can_partition([5, 2, 3])
- # ([5], [2, 3])
- # Out[1]: True
- #
- # In [2]: can_partition([2, 3, 2, 1, 1, 1, 2, 1, 1])
- # ([2, 3, 2], [1, 1, 1, 2, 1, 1])
- # Out[2]: True
- #
- # In [3]: can_partition([1, 1, 3])
- # Out[3]: False
- #
- # In [4]: can_partition([1, 1, 3, 1])
- # Out[4]: False
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement