All problems
Win Rate from Pairwise Outcomes
Problem
Return the win rate from outcomes coded 1 for a win, 0 for a tie, and -1 for a loss, counting a tie as half a win: (wins + 0.5 * ties) / n. Return 0.0 for an empty list.
Test cases
case 1
in: [[1,1,-1,0]]
expected: 0.625
case 2
in: [[0,0,0]]
expected: 0.5
case 3
in: [[]]
expected: 0
case 4
in: [[-1,-1]]
expected: 0
case 5
in: [[1,-1]]
expected: 0.5
Starter codePython
def win_rate(outcomes):
# Your code here
pass5 test cases · run your code against them in the editor