Rank a list of scores with "skips"
T-SQL (40)
SELECT RANK()OVER(ORDER BY B DESC)
FROM @
Assume @
is a table containing the scores as rows.
J (7 6)
EDIT: Oh, wait! It doesn't need to be a function!
>:i.~y
Thank god for i.~
...
>:@:i.~
Or as a named function (3 chars more, but not functionally different):
f=:>:@:i.~
Run tests:
f=:>:@:i.~
f 10 10 6 6 4 0
1 1 3 3 5 6
f 10 9 8
1 2 3
f 0 0 0
1 1 1
f 16 15 15 12 11 11 10 9 9 9 8 2 2 2 0
1 2 2 4 5 5 7 8 8 8 11 12 12 12 15
Python (33 characters)
lambda x:[1+x.index(i)for i in x]
Functionally the same as my J answer.