All problems
Preference Win Rate Computation
Problem
Compute a win rate from wins, losses, and ties.
With tie_mode 'exclude' ties are dropped, with 'half' they count as 0.5, and any other value (including 'include') counts them as wins. Return 0.0 when the denominator is zero.
Hint
Win rates are only comparable when everyone handles ties the same way.
Test cases
case 1
in: [8,2,0,"exclude"]
expected: 0.8
case 2
in: [8,2,5,"half"]
expected: 0.7
case 3
in: [8,2,5,"include"]
expected: 0.8666666666666667
case 4
in: [0,0,0,"half"]
expected: 0
Starter codePython
def preference_win_rate(wins, losses, ties, tie_mode):
# Your code here
pass4 test cases · run your code against them in the editor