Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need help Problem 3 Write a function is straight that takes in a list of 5 cards and returns whether the ranks of the cards

image text in transcribed

need help

Problem 3 Write a function is straight that takes in a list of 5 cards and returns whether the ranks of the cards form a straight. Cards will be specified the same way as in Problem 1. A straight is a set of cards in which the card ranks are consecutive. Card ranks go from 2 to 9, then Ten, Jack, Queen, and King. The Ace can count as the highest rank or the lowest rank when determining a straight. Suit is irrelevant when determining whether the cards form a straight. Hint: start by finding the high card, then determine if the next 4 lower ranks are present. If the high card is an Ace, check whether the other ranks are King, Queen, Jack, and Ten OR 2, 3, 4, and 5. Sample test cases: Input: ['T', 'S', 'S', 'S', 'AS'] Output: True *. 'AS', 'S', 'TS] Input: ['JS', Output: True Input: ['4', '55', '60', 'D', '9H 1 Output: False Input: ['30', 20', '4', 'AD', '5C'] Output: True Problem 4 Write a function max_of_a_kind that takes a list of 5 cards and returns the rank of the card that appears most frequently. If there is a tie (two pairs or all five cards different), you should return the rank of the highest tied card (Ace high, followed by King, Queen, Jack, Ten, then 9 down to 2). The suit is irrelevant to determining the max_of_a_kind. Hint: you may wish to create a dictionary that counts how many times each rank appears. Sample test cases: Input: 1'2', '25', 'D', '2H', 'AD') Output: 2 BH 60' '90 *65') Input: ['BH'. Output

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

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

=+ For what reasons can and do unions go on strike?

Answered: 1 week ago

Question

=+ Is secondary industrial action common and/or legal?

Answered: 1 week ago