Feb-06-2021, 01:42 AM
Hello everyone
If the sum of the numbers in the list1 is not 4000, it should give the closest value to 4000. The maximum number of elements of the output is 6.
For example
Sum = 4000
list1 = [400, 600, 600, 1000]
output1 = [400,600, 1000,1000,1000]
output2 = [600, 600, 600, 600, 600,1000]
...
outputn = [1000,1000, 1000,1000]
If the sum was 4005, the results would still be the same.
what code do i need?
Thank you in advance for your help.
If the sum of the numbers in the list1 is not 4000, it should give the closest value to 4000. The maximum number of elements of the output is 6.
For example
Sum = 4000
list1 = [400, 600, 600, 1000]
output1 = [400,600, 1000,1000,1000]
output2 = [600, 600, 600, 600, 600,1000]
...
outputn = [1000,1000, 1000,1000]
If the sum was 4005, the results would still be the same.
what code do i need?
Thank you in advance for your help.