Problem:
- I have a list of integer ranking values, lets say 0 is lowest 100 is highest.
- I have a list of ranges (stored as index into ranking array and number of items)
Core rules:
- ranges cover whole list of values
- every range has at least 1 element
- ranges are consecutive, without overlapping values
- list of rankings can’t be sorted in any way, just to make this clear
Given only these rules, it is simple to equally (or almost by 1 equally) partition them, what I need to do is to take into an account the ranking and have these ranges shifted in a way that the higher ranking value is more likely to end up at as the first element of the range, where as lowest ranking has the higher chance to end up as last element of the range.
The longest range should not exceed the total number of ranges.
Example for list of 246 elements with 15 ranges: [0, 0, 90, 50, 50, 0, 90, 50, 40, …], I could get [[0, 2], [2, 3], [5, 3], …, [230, 15], [245, 2]]
I need efficient solution for general case of 250 – 500 ranking being contained within 15 – 30 ranges.
I am not sure what kind of algorithm this could be, whether this is not something very specific, but first wanted to ask before reinventing the wheel.
4