Minimum Sum Partition Problem Python