Cody

# Problem 44723. Let's Make A Deal: The Player's Dilemma

Solution 1722859

Submitted on 7 Feb 2019 by Alfonso Nieto-Castanon
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
H = 2; Ph = [0 0.55 0.45;0 0 1;0 1 0]; Pws_correct = 0.6452; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

2   Pass
H = 3; Ph = [0 0.55 0.45;0 0 1;0 1 0]; Pws_correct = 0.6897; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

3   Pass
H = 2; Ph = [0 0.25 0.75;0 0 1;0 1 0]; Pws_correct = 0.8; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

4   Pass
H = 3; Ph = [0 0.25 0.75;0 0 1;0 1 0]; Pws_correct = 0.5714; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

5   Pass
H = 2; Ph = [0 0.5 0.5;0 0 1;0 1 0]; Pws_correct = 0.6667; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

6   Pass
H = 3; Ph = [0 0.5 0.5;0 0 1;0 1 0]; Pws_correct = 0.6667; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

7   Pass
H = 2; Ph = [0 0.80 0.20;0 0 1;0 1 0]; Pws_correct = 0.5556; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

8   Pass
H = 3; Ph = [0 0.80 0.20;0 0 1;0 1 0]; Pws_correct = 0.8333; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

9   Pass
H = 2; Ph = [0 0.60 0.40;0 0 1;0 1 0]; Pws_correct = 0.6250; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

10   Pass
H = 3; Ph = [0 0.60 0.40;0 0 1;0 1 0]; Pws_correct = 0.7143; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

11   Pass
H = 2; Ph = [0 0.23 0.77;0 0 1;0 1 0]; Pws_correct = 0.8130; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

12   Pass
H = 3; Ph = [0 0.23 0.77;0 0 1;0 1 0]; Pws_correct = 0.5650; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

13   Pass
H = 2; Ph = [0 0.27 0.73;0 0 1;0 1 0]; Pws_correct = 0.7874; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

14   Pass
H = 3; Ph = [0 0.27 0.73;0 0 1;0 1 0]; Pws_correct = 0.5780; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

15   Pass
H = 2; Ph = [0 0.90 0.10;0 0 1;0 1 0]; Pws_correct = 0.5263; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

16   Pass
H = 3; Ph = [0 0.90 0.10;0 0 1;0 1 0]; Pws_correct = 0.9091; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

17   Pass
H = 2; Ph = [0 1 0;0 0 1;0 1 0]; Pws_correct = 0.5; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

18   Pass
H = 3; Ph = [0 1 0;0 0 1;0 1 0]; Pws_correct = 1; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

19   Pass
H = 2; Ph = [0 0.37 0.63;0 0 1;0 1 0]; Pws_correct = 0.7299; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

20   Pass
H = 3; Ph = [0 0.37 0.63;0 0 1;0 1 0]; Pws_correct = 0.6135; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

21   Pass
H = 2; Ph = [0 0.01 0.99;0 0 1;0 1 0]; Pws_correct = 0.9901; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

22   Pass
H = 3; Ph = [0 0.01 0.99;0 0 1;0 1 0]; Pws_correct = 0.5025; Pws = MontyHall(H, Ph); assert(isequal(round(Pws,4),Pws_correct))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!