Challenge:
In the language of your choice, write a program that generates a leaderboard with random scores and outputs it, then take a new score as input and check if it can be placed in the leaderboard, and output which place it is in.
Specifications:
- You must generate a list of 50 "random" scores, in descending order and output it
- The "random" scores will range from 0 to 255
- If 2 scores are the same, it doesn't matter which is placed first in the descending order
- If the input score isn't higher than any of the scores in the list, output 0 or a falsy statement. (the input will be 0 to 255, no need to check)
- If the score IS higher than a score in the list, output the position it would take in the leaderboards.
- Generate and output the leaderboards/list first in descending order, before taking input.
Example I/O:
Random list: (the three dots are so I don't have to add 50 line text here. You should output each score. 12 is the 50th place)
201
192
178
174
...
...
12
Input:
180
Output:
3
(because this score would place no.3 in the leaderboards)
Input 2:
7
Output 2:
0
(because it is lower than everything on the leaderboard)
This is a code-golf so shortest code wins.
10 9 9 7 5
and I get an input of9
? \$\endgroup\$