Question: 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:

Program: Python, running in Jupyter Question: For the listed hand types, write

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!