Answered step by step
Verified Expert Solution
Link Copied!

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:

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions