1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zubka84 [21]
3 years ago
11

Write a function flush that takes as input a list of five cards, tests whether it is a flush (Note: straight flush is not a flus

h!) and return a boolean value. If the entry is anything other than five distinct cards, it should return (not print!) the message "This is not a valid poker hand".
Computers and Technology
1 answer:
melamori03 [73]3 years ago
5 0

Answer:

Explanation:

ef poker(hands):

   scores = [(i, score(hand.split())) for i, hand in enumerate(hands)]

   winner = sorted(scores , key=lambda x:x[1])[-1][0]

   return hands[winner]

def score(hand):

   ranks = '23456789TJQKA'

   rcounts = {ranks.find(r): ''.join(hand).count(r) for r, _ in hand}.items()

   score, ranks = zip(*sorted((cnt, rank) for rank, cnt in rcounts)[::-1])

   if len(score) == 5:

       if ranks[0:2] == (12, 3): #adjust if 5 high straight

           ranks = (3, 2, 1, 0, -1)

       straight = ranks[0] - ranks[4] == 4

       flush = len({suit for _, suit in hand}) == 1

       '''no pair, straight, flush, or straight flush'''

       score = ([1, (3,1,1,1)], [(3,1,1,2), (5,)])[flush][straight]

   return score, ranks

>>> poker(['8C TS KC 9H 4S', '7D 2S 5D 3S AC', '8C AD 8D AC 9C', '7C 5H 8D TD KS'])

'8C AD 8D AC 9C'

You might be interested in
(03 MC)Why is it important to set goals and share them with others?
Ad libitum [116K]

Answer:

answer is b

Explanation:

hope it was helpful

3 0
2 years ago
Which of the following software program provides for email communication
olga2289 [7]
If "Outlook" is one of the options then thats the answer.
6 0
3 years ago
Read 2 more answers
Students can use eNotes to type notes directly on screen and
zalisa [80]
A. review or print them later
6 0
3 years ago
Read 2 more answers
In a complex system, many subsystems interact with one another. How do these systems interact in terms of inputs and outputs?
Artemon [7]

Answer:

I think in there transmission you know inputs into ports like for their own

Explanation:

likeslike Spanish and is obviously inputs and outputs their portsinto the portsdifferent ports you know

4 0
3 years ago
Is anyone else excited for sephiroth (I think I spelt it wrong) in smash. And if you arn't are you excited for christmas
Fed [463]

Answer: idek what that is but okay ;v;

7 0
3 years ago
Other questions:
  • What combination of words and boolean operators would display all audio files about chiropractic?
    6·1 answer
  • Lenovo's ThinkPad laptop computers is designed in the United States, the case, keyboard, and hard drive are made in Thailand; th
    14·1 answer
  • Does functionality provided by the app play an important role in a decision to
    13·1 answer
  • Imagine that the following two lines of code are placed inside a
    11·1 answer
  • Who developed the idea of a universal network?
    11·1 answer
  • What component uses thermal paste to attach the heat sink?
    13·1 answer
  • Name various phases of SDLC in Rational Unified Process (RUP)
    7·1 answer
  • Here is a list of storage devices:
    5·1 answer
  • What is the output of the following program?
    8·1 answer
  • Which tool allows users to share code and also serves as a social networking
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!