Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Poker hand python 3.4 I need help with function poker_hand(cards): Straight (five cards when rearranged will form a run of five consecutive cards) Four of

Poker hand python 3.4

I need help with function poker_hand(cards):

Straight (five cards when rearranged will form a run of five consecutive cards)

Four of a kind (four or five cards of the same rank)

Three of a kind (exactly three cards of the same rank)

One pair (at least one pair of the same rank, but not four cards of the same rank)

High card (no cards of identical rank that also do not form a straight)

There's class to use.

class Card: suit_sym = {0: '\u2663', 1: '\u2666', 2: '\u2665', 3: '\u2660'} rank_sym = {0: '2', 1: '3', 2: '4', 3: '5', 4: '6', 5: '7', 6: '8', 7: '9', 8: '10', 9: 'J', 10: 'Q', 11: 'K', 12: 'A'} def __init__(self, n): self._id = n def rank(self): return self._id % 13 def suit(self): return self._id // 13 def __repr__(self): return Card.rank_sym[self.rank()] + Card.suit_sym[self.suit()] def __lt__(self, other): return self._id def __eq__(self, other): return self._id == other._id 

Below is the examples.

I'm struggling with how to start, and develop the code for this.

Please help me.

image text in transcribed

The numbers given to the constructors below are in the range 0 through 51, as in the examples from lecture and the textbook. You will need to use the rank method of the Card class to extract the rank of each Card When you run the provided home work3.py file, you will see the actual rank and suit of each card printed on the screen Function Call Return Value an (Card (22) Card (16), Card (6) Card (17), Card (19) One pair' poker hand ([Card (22), Card (16), Card (9), Card (35), Card (19) j Three of a kind' poker-hand ([Card (51) Card (38) Card (6) Card (32) Card (12) j) Three of a kind poker-hand ([Card (11), Card (12) Card (14), Card (16), Card (30) High card' poker-hand [Card (3), Card (16), Card (17), Card (29), Card (42) j) Four of a kind' Straight. poker-hand [Card (3), Card (5), Card (6), Card (4), Card (7) poker-hand ([Card (11) Card (12) Card (13) Card (14) Card (15) J) High card

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_2

Step: 3

blur-text-image_3

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

8. Managers are not trained to be innovation leaders.

Answered: 1 week ago