% lecture 1: Enumeration % 5-Card Stud % Probability of 3 of a kind tic Pair3 = 0; Total = 0; for c1=1:48 for c2 = c1+1:49 clc disp([c1,c2]) for c3 = c2+1:50 for c4 = c3+1:51 for c5 = c4+1:52 Total = Total + 1; Hand = [c1,c2,c3,c4,c5]; Value = mod(Hand-1,13)+1; Suit = ceil(Hand/13); N = zeros(1,13); for n=1:13 N(n) = sum(Value == n); end [N,a] = sort(N, 'descend'); if ((N(1) == 3)*(N(2) < 2)) Pair3 = Pair3 + 1; end end end end end end disp(' 3-of-a-kind # hands') disp([Pair3, Total]) toc