I have a large sorted set of numbers that I need to distribute into x ranges of numbers, such that each range contains an equal number of elements from the set, and the ranges end between the two closest elements.
For example, when x = 4
, with this set of numbers
[1, 1, 3, 5, 7, 10, 14, 25, 35, 50, 75, 100, 120, 150, 200, 260]
the output should be
[1, 6(midpoint of 5,7), 30(midpoint of 25,35), 110(midpoint of 100,120), 260]
Bonus for something I can easily translate into code as I'm not very mathematically inclined.
Also I'm not sure which category this would be under so please feel free to help me with tags.