#287 · Heaps · Intermediate · 65 XP · about 12 min
An arcade machine shows the three best scores so far and updates the display after every game. Write top_three(scores) that takes the scores in the order the games were played and returns a list of lists, one per game: the highest three scores seen up to and including that game, from highest to lowest.
Before the third game there are fewer than three scores, so the list shows all of them. Equal scores are separate entries: two games that both scored 50 can both appear.
top_three([40, 75, 20, 90, 75]) # returns [[40], [75, 40], [75, 40, 20], [90, 75, 40], [90, 75, 75]] top_three([5, 5, 5, 5]) # returns [[5], [5, 5], [5, 5, 5], [5, 5, 5]] top_three([]) # returns []
First solves only, ranked by stars and then time.