Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program: Python, running in Jupyter Question: For the listed hand types, write the code so that the length of all possible hands of that specific
Program: Python, running in Jupyter
Question: For the listed hand types, write the code so that the length of all possible hands of that specific type is printed.
Hand types: two pair, three of a kind, four of a kind, flush, straight, straight flush, pair
Example of code:
print(len(two_pair)) = 123552
and print (len(three_of_a_kind)) = 54912
-------------------
Code should work if the following is true:
print(len(four_of_a_kind)) = 624
print (len(flush)) = 5108
print(len(straight)) = 10200
print(len(straight_flush)) = 36
print(len(pair)) = 1098240
In [2]: from itertools import combinations two_pair[] for c1,c2,c3 in combinations (values,3): for s11,s12 in combinations (suits,2): for s21,s22 in combinations (suits,2): for s3 in suits two_pair.append ((c1+s11, c1+s12, c2+s21, c2+s22, c3+s3)) two_pair.append ((c2+s11, c2+s12, c3+s21, c3+s22, c1+s3)) two_pair.append((c3+s11, c3+s12, c1+s21, c1+s22, c2+s3)) print (len(two_pair)) three_of_a_kind [] for c1,c2,c3 in combinations (values,3) for s11,s12,s13 in combinations (suits,3): for s2 in suits for s3 in suits three_of_a_kind.append ((c1+s11, c1+s12, c1+s13, c2+s2, c3+s3)) three_of_a_kind.append((c2+s11, c2+s12, c2+s13, c3+s2, c1+s3)) three_of_a_kind.append((c3+s11, c3+s12, c3+s13, c1+s2, c2+s3)) In [2]: from itertools import combinations two_pair[] for c1,c2,c3 in combinations (values,3): for s11,s12 in combinations (suits,2): for s21,s22 in combinations (suits,2): for s3 in suits two_pair.append ((c1+s11, c1+s12, c2+s21, c2+s22, c3+s3)) two_pair.append ((c2+s11, c2+s12, c3+s21, c3+s22, c1+s3)) two_pair.append((c3+s11, c3+s12, c1+s21, c1+s22, c2+s3)) print (len(two_pair)) three_of_a_kind [] for c1,c2,c3 in combinations (values,3) for s11,s12,s13 in combinations (suits,3): for s2 in suits for s3 in suits three_of_a_kind.append ((c1+s11, c1+s12, c1+s13, c2+s2, c3+s3)) three_of_a_kind.append((c2+s11, c2+s12, c2+s13, c3+s2, c1+s3)) three_of_a_kind.append((c3+s11, c3+s12, c3+s13, c1+s2, c2+s3))Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started