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
How does 5G technology enhance the Internet of Things (IoT)?
SashulF [63]

Answer:

<em><u>5G Will Quickly Become The New Standard For Cellular Networks. The Internet of Things (IoT) is rapidly developing and expanding. ... 5G will increase cellular bandwidth by huge amounts, making it much easier for the Internet of Things to network large numbers of devices together.</u></em>

Explanation:

Hope its help

5 0
2 years ago
List and briefly defined categories of security services.
Fynjy0 [20]
There are six categories of security services: authenticiation, access control, data confidentiality, data integrity, nonrepudiation, and availability service. First, is authentication service, which defines as the assurance that the communicator is legitimate and is the one that it claims to be. It can either be peer entity or data origin authentication. Second, access control which is to prevent any unauthorized uses of resources. After one is being authenticiated, then this service limit/controls who access? what accessing rights to the resources are allowed depending on the identified individuals. Data confifentiality: the protection of data from unauthorized disclosure. Data integrity: the assurance that data received are exactly as sent by an authorized entity (e.t.c, contain no modificafion, insertion, deletion, or replay).
7 0
3 years ago
Can someone pelaseee help
aalyn [17]

Answer:

Explanation:

develloppemetn de grace en option est logiquement une biologiste experimenter des annes 1256 a toulouse en france

6 0
2 years ago
Write a sub-program to display the acceleration of car. The program should ask initial velocity, final velocity, and time taken
LekaFEV [45]

Explanation:

If your asking the program in modular programming of Q-Basic & in sub procedure then here it is.

I hope it will help you..

<em>-</em><em> </em><em>Regards</em><em> </em><em>Rishab</em><em>.</em><em>.</em>

8 0
1 year ago
A(n)<br> is a fast compute with lots of storage. pls help
Pachacha [2.7K]

Answer:

Surface Laptop 3 - 15", Platinum (metal), AMD Ryzen 5 3580U, 8GB, 128GB

4 0
3 years ago
Read 2 more answers
Other questions:
  • The Modified Greiss chemical test is used to detect the presence of what chemicals that indicate muzzle to target distance?
    11·1 answer
  • A switch operates in the OSI reference model __________ layer and uses the __________ address to forward packets.
    8·1 answer
  • Select the statement that accurately describes why the Italics function is being used in the sentences below.
    8·1 answer
  • Explain the history of computing of mechanical era
    14·2 answers
  • EXCEL 2016:
    8·2 answers
  • With a(n) ______, a search engine will show ads that have the keyword typed exactly as the searcher used, but may also have othe
    6·1 answer
  • Which steps are correct for creating a document from a user-defined template?
    15·1 answer
  • Please answer me <br> in Assignment - Algorithms
    10·1 answer
  • I need the answers. i don’t get this
    11·1 answer
  • What is the output for the following program?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!