Untitled

 avatar
unknown
plain_text
3 years ago
675 B
8
Indexable
Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

clc
clear all

count1=0;
count2=0;
for i=1:1000
V=[1:3];
totala=0;
totalb=0;
a=randi([1,3],1,1);
totala=a+totala;
count=2;
while(1)
R=V(find(V~=a));
a=R(randi([1,2],1,1));
if(count==2)
totalb=a+totalb;
count=count-1;
else
totala=a+totala;
count=count+1;
end
if(totala==8)

count1=count1+1;
break;
end
if(totalb==8)
  
count2=count2+1;
break;
end
if(totala>8)
  
count2=count2+1;
break;
end
if(totalb>8)
  
count1=count1+1;
break;
end
  
  
end
end
fprintf('Probability of winning A is %f\n',count1/1000);
fprintf('Probability of winning B is %f\n',count2/1000);
Editor is loading...