15 is correct.
MATLAB Code to solve the same using Monte Carlo:
Code:
n = 100000;
total_hours = zeros(n,1);
for i = 1:n
exit = 0;
hours = 0;
while exit == 0;
Door = ceil(rand*3);
switch Door
case 1
hours = hours + 3;
exit = 1;
case 2
hours = hours + 5;
exit = 0;
otherwise
hours = hours + 7;
exit = 0;
end
end
total_hours(i,1) = hours;
end
answer = mean(total_hours)
Last edited: May 19, 2013