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
I need help with this plz! It’s for a test and I really need help
Bas_tet [7]

Answer:

c

Explanation:

assuming you are coding in python and have not install any calculation codes, the answer is most likely c

4 0
3 years ago
PL I BEG YOU HELP
Murrr4er [49]

Answer:

Answers in explanation. Try to ask one question at a time, it is easier for people to answer single questions and you will get answers faster.

Explanation:

15. A

16. D

17. B + C

18. A+B+D

19. B+C+D

**20. is NOT Planned personal leave for documentation developers and proof readers. The other 4 answers are correct

21. Presentation notes + Outline

22.B

23.D (im not entirely sure about this one)    

8 0
3 years ago
Without a/an ________. a computer is useless
Len [333]
Without a/an Operating system. a computer is useless
3 0
3 years ago
Interchanges of ideas in forums and internet news groups are functions of which domain?
Anarel [89]
I believe that the answer to the question provided above is that the  <span>Interchanges of ideas in forums and internet news groups are functions of the information domain.</span>
Hope my answer would be a great help for you.    If you have more questions feel free to ask here at Brainly.
5 0
3 years ago
Implement switch/case or if/else ladder for menu control. Update the currency conversion program. If the user enters an invalid
Sindrei [870]

Answer:

I need some time i answering your question please follow me and thanks

6 0
2 years ago
Other questions:
  • A ______________ is a document created when planning resource management to help promote teamwork and clarify team communication
    13·1 answer
  • How does this splitting wedge make work easier?
    15·1 answer
  • Your employer gives you a list of all chemicals in the entire building and the location of the SDS collection, and he asks you t
    15·2 answers
  • Which PowerPoint options can users customize?
    9·1 answer
  • _____________ data is what is translated to digital format so it can be stored in a computer.
    10·1 answer
  • In Access, it is possible to have _______________ fields, that is, fields that can contain more than one value.
    9·1 answer
  • If you would like to compare information on two different Web pages, you should _____.
    13·2 answers
  • To obtain your class E learner license, youll need too _
    9·1 answer
  • Can some one help me with this please
    5·1 answer
  • after adding a sound to a slide, the audio tools tab will allow you to apply artistic effects and quick styles to your sound ico
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!