All problems
League Table Update
Problem
Update a league table after one game.
Each row is [name, wins, losses, rating]. Increment the winner's wins and the loser's losses, then apply a fixed K = 16 Elo update to both ratings (winner scored 1.0, loser 0.0). Return the updated table as deep copies.
Hint
Ratings are read before the game and updated only after both tallies change.
Test cases
case 1
in: [[["A",5,3,1520],["B",4,4,1480],["C",6,2,1600]],"A","B"]
expected: [["A",6,3,1527.0830138598033],["B",4,5,1472.9169861401967],["C",6,2,1600]]
case 2
in: [[["X",0,0,1500],["Y",0,0,1500]],"Y","X"]
expected: [["X",0,1,1492],["Y",1,0,1508]]
case 3
in: [[["A",1,0,1550],["B",0,1,1450]],"B","A"]
expected: [["A",1,1,1539.7589600031538],["B",1,1,1460.2410399968462]]
Starter codePython
def league_table_update(table, winner, loser):
# Your code here
pass3 test cases · run your code against them in the editor