none
How-to find the best selection of numbers in a pool? RRS feed

  • General discussion

  • Hi

    I have a challenge that I need to solve:
    Given a set 20 random numbers between 1 and 700.
    Given a pool limit of 250 (or any given limit)

    I need to write some code that find the best selection of the 20 numbers that fills each pool, the best way.


    E.g.:
    My random numbers: 23,12,45,600,54,1,23,3,4,67,89,32,18,32,20,10,5,6,7,190
    My pool limit is 250


    Pool1:
    I sees that the number 600 is too large, and the pool is full

    Pool2:
    Then I take a new pool, and try to fill it optimal with the rest of the numbers:
    190 + 18 +32 + 10 = 250

    Pool3:
    Then I take a new pool, and try to fill it optimal with the rest of the numbers, and so on


    The challenge is to create the optimal selection of the numbers to fill each pool to the rind.


    So far my code just take the numbers greater than the limit and put those in an own pool, and then take the rest of the numbers and then add them one by one, until the limit is reach, and then I create a new pool
    This works, but is is not an optimal solution


    Anyone have a clue how this challenge may be solved?

    Thanks:-)

    /Peter





    • Edited by Peter_Moe Tuesday, January 2, 2018 8:35 AM
    • Changed type Bill_Stewart Wednesday, February 14, 2018 6:19 PM
    • Moved by Bill_Stewart Wednesday, February 14, 2018 6:19 PM This is not "do my homework project for me" forum
    Tuesday, January 2, 2018 8:35 AM

All replies