question 70 Lists & Tuples · hard
A leaderboard with shared places
Print a quiz leaderboard from (name, score) tuples: highest score first, and players with the same score in alphabetical order of name. Players with equal scores share a place, and the next place skips accordingly (scores 91, 88, 88, 70 get places 1, 2, 2, 4). Each line is <place> <name> <score>.
Input
results, a list of (name, score) tuplesOrderscore from high to low; equal scores by name A–Z
Placesequal scores share a place; the next different score gets its position counting from 1
ExamplesBen 88, Ana 91, Dee 70, Cy 88 →
1 Ana 91, 2 Ben 88, 2 Cy 88, 4 Dee 70Expected output4 lines
- 11 Ana 91
- 22 Ben 88
- 32 Cy 88
- 44 Dee 70