Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
win=0;
Pass=0;
for i=1:100
prize=randi(3);
doors=[0 0 0];
pick=Monty(doors);
pick=floor(pick);
if pick<1 || pick>3
win=0;
break;
else
doors(pick)=1;
end
if pick==prize
% Random select from other doors
if rand>0.5
doors(find(doors==0,1))=2;
else
doors(find(doors==0,1,'last'))=2;
end
else %
% Pick other and not prize door
reveal=setxor(prize,setxor(pick,[1 2 3]));
doors(reveal)=2;
end
pick=Monty(doors);
pick=floor(pick);
if pick==prize
win=win+1;
end
end % Monty Loops
win % Display number of wins
if win>50,Pass=1;end
assert(isequal(Pass,1))
win =
76
|
Which values occur exactly three times?
3817 Solvers
1965 Solvers
What is the distance from point P(x,y) to the line Ax + By + C = 0?
278 Solvers
Getting the row and column location from a matrix
236 Solvers
Getting the absolute index from a matrix
211 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!