Minimum Sum Partition Problem Dynamic Programming Python