Need help for a programming function which needs to compute numbers !

zdaar

New member
Joined
Aug 29, 2015
Messages
1
Hi everyone !

I am a beginner python programmer who is really bad at math :/ Courses on the way tho.

My problem is the following :

I need to enter a series of numbers in a list, and divide them the best way possible with the least remainder when adding them for a total value of 40.

Here is an exemple :

total_to_get_to = 40
list = [8, 12, 7, 5, 5, 13, 15, 13, 7, 5, 3, 2, 10, 12, 13, 15]

This function needs to make the best addition of these numbers to get the most times to 40.

First process cycle would go :
8 + 12 + 7 + 13 = 40
These numbers would get removed from the list, and it would try to get as close as 40 as it can with the remaining numbers.

I have no idea how to do it in a simple way, so I stumbled upon this forum looking for math help :)

Thanks in advance to anyone taking time to read and/or answer !
 
Top