Cody

Solution 1699438

Submitted on 26 Dec 2018 by Binbin Qi
  • Size: 21
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
M = [ NaN 1 ; 0 NaN ]; assert(isequal(winprob(M,1),1)); assert(isequal(winprob(M,2),0)); 2

ans = 2

2   Pass
M = [ NaN 0.7 ; 0.3 NaN ]; assert(isequal(winprob(M,1),0.7)); assert(isequal(winprob(M,2),0.3)); 3

ans = 3

3   Pass
M = zeros(8)+NaN; for i=1:7 for j=i+1:8 r=rand(); M(i,j)=r; M(j,i)=1-r; end end epsilon=1e-8; totprob=0; for i=1:8 totprob=totprob+winprob(M,i); end assert(abs(totprob-1)<epsilon);