Python: Recursive: Integer Partition

Write the recursive function partition that takes an integer n and returns a list of tuples containing all the integer partitions of n. The list should be sorted in ascending order. More information about integer partition can be found here.


partition(2) -> [(1, 1), (2, )]
partition(3) -> [(1, 1, 1), (1, 2), (3,)]
partition(5) -> [(1, 1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 3), (1, 2, 2), (1, 4), (2, 3), (5,)]

Test 1    

Test 2    

Test 3    

Test 4    

Test 5    

Test 6    

Test 7    

Test 8