2022-7: Just Golfing Around
Apologies to the code golfers out there, but this problem has nothing to do with code golf! Instead, it addresses the problem of assigning places in a golf tournament. In regular golf, lower scores place higher – the lowest score places first and the highest score places last.
Write a function that:
- takes a right argument that is a non-decreasing vector or scalar of strictly positive integers, representing a set of scores.
- returns a numeric vector of the place for each score; for duplicate scores, it returns the average of the places they hold.
Hint: This problem has several viable approaches including using key f⌸, or partition X⊆Y, or interval index X⍸Y.
Examples:
(your_function) 1 2 3 4 5 1 2 3 4 5 (your_function) 68 71 71 73 1 2.5 2.5 4 (your_function) 67 68 68 69 70 70 70 71 72 1 2.5 2.5 4 6 6 6 8 9 (your_function) 6⍴70 3.5 3.5 3.5 3.5 3.5 3.5 (your_function) ⍬ ⍝ this should return an empty vector (your_function) 67 ⍝ should work with a scalar argument 1
your_function ←
Solutions

