% ECE 341 Lecture #2 % 5-Card Stud % Combinations and Permutations Pair4 = 0; FullHouse = 0; Pair3 = 0; Pair22 = 0; Pair2 = 0; for i0 = 1:1e5 X = rand(1,52); [a,Deck] = sort(X); Hand = Deck(1:5); 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) == 4) Pair4 = Pair4 + 1; end if ((N(1) == 3)*(N(2) == 2)) FullHouse=FullHouse + 1; end if ((N(1) == 3)*(N(2) < 2)) Pair3 = Pair3 + 1; end if ((N(1) == 2)*(N(2) == 2)) Pair22 = Pair22 + 1; end if ((N(1) == 2)*(N(2) < 2)) Pair2 = Pair2 + 1; end end disp(' 4-of-kind Full House 3-of-kind 2-Pair Pair') disp([Pair4, FullHouse,Pair3,Pair22,Pair2])