Ok, so... i have a list of numbers ranging from 0 to 1. Let's say the list is 20 items long for example:
[0.3573617561804454, 0.07342389373929337, 0.06378891650870389, 0.5511799059130659, 0.2149869017013486, 0.9078793201337962, 0.6416645206383136, 0.08612996915296112, 0.3389149731962322, 0.27043204930306286, 0.4394280879520357, 0.7139129976601778, 0.9426831544676971, 0.5704199007458483, 0.7661935177777641, 0.5012058242125581, 0.3960034601385938, 0.11300340597511527, 0.4640564412846996, 0.46884307251796087]
How do i find the combination closest to average 0.5 and under average 0.5 consisting of 10 items?
My first attempt was sorting the list from high to low and then taking items 1 to 10 highest items and getting the average of them, if it was over 0.5, I would take item 2 to 11 and do the same until it was under 0.5.
This is not optimal because there might be scenarios where the best combination is a mix between some of the highest numbers and some of the lowest numbers