I ran into this problem while working on another challenge I'm making for this site. In that challenge I utilize "Mario Kart 8 Scoring". The amount of points the player in kth place gets is represented by this 1-indexed array: [15,12,10,9,8,7,6,5,4,3,2,1]. So 1st place gets 15 points, 2nd place gets 12 points, etc.
It's easy enough to assign points like this, however the tricky part comes with how I handle ties. What I do is give each tying player the average of the points given for each tying place. For example, if only 1st and 2nd tied, then both players get (15+12)/2 = 13.5 points. (Note: You're allowed to round to the nearest int, so 13 or 14 are both also acceptable.) Then 3rd - 12th place get the normal amount of points for their position.
Challenge
Given 12 non-negative integer scores that are decreasingly sorted, output the number of points each player gets. You can also take the points list [15,12,10,9,...] as input. Note that the number of points each player gets does not depend on the actual values of the scores, but how they compare to the other scores.
Test Cases
- [21,21,15,14,12,9,6,5,4,3,2,1] => [14,14,10,9,8,7,6,5,4,3,2,1]
- [20,15,15,15,10,9,8,7,6,5,4,3] => [15,10,10,10,8,7,6,5,4,3,2,1]
- explanation: (12+10+9)/3 = 10.3333
- [1,1,1,1,1,1,1,1,1,1,1,1] => [7,7,7,7,7,7,7,7,7,7,7,7]
- explanation: (15+12+10+9+8+7+6+5+4+3+2+1)/12 = 6.8333
- [20,20,20,20,10,10,10,9,8,7,6,5] => [12,12,12,12,7,7,7,5,4,3,2,1]
- explanation: (15+12+10+9)/4 = 11.5, (8+7+6)/3 = 7
- [100,99,98,95,95,95,94,93,93,92,91,91] => [15,12,10,8,8,8,6,5,5,3,2,2]
- explanation: (9+8+7)/3 = 8, (5+4)/2 = 4.5, (2+1)/2 = 1.5
Related: Rank a list of scores with "skips"