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
5. The problem domain refers to the
solong [7]

Answer:

The problem domain refers to the support options.

6 0
3 years ago
What is an IF statement used for?
kiruha [24]

The IF statement is a decision-making statement that guides a program to make decisions based on specified criteria. The IF statement executes one set of code if a specified condition is met (TRUE) or another set of code evaluates to FALSE.

8 0
2 years ago
Which of the following office online apps is most effective for creating multi media presentation
Brrunno [24]
Google slides is the best out there
3 0
3 years ago
Read 2 more answers
Why did industrial revolution begin Britain?​
allochka39001 [22]

Answer:

Britain also happened to have a wealth of coal, iron, and other resources in a relatively small area, which would help kick-start the Industrial Revolution. Its growing Colonial Empire also provided a ready-made (and captive) market for surplus goods, providing further impetus for entrepreneurs and new industrialists

7 0
1 year ago
Read 2 more answers
A company is executing a strategy to encrypt and sign all proprietary data in transit. The company recently deployed PKI service
Softa [21]

Answer:

A. S/MIME

B. TLS

C. Kerberos

Explanation:

PKI : Public Key Infrastructure is a technique which will allow services or applications to communicate securely across the unsecured network or internet.

PKI mainly consist of CA or Certificate Authority who can issue digital certificates or they are also known as trusted CA.  exmaples are godaddy, digicert, verizone, symmantec, etc.. and RA also known as Registration Authorities and they verify if the requested certificates can be stored at CA. Keys will be stored in the central directory.It will also consists of certificate management system and the policies governing PKI.

S/MIME : Secure/Multipurpose Internet Mail Extensions which use assymentric cryptography and sign the MIME data.   S/MIME will provide services like  Authentication, Encryption , Integrity, Privacy and Non repudiation for messaging applications

SMIME uses certificates which can be self signed or CA certified. It specifies MIME type as  application/pkcs7-mime  while transmitting the data.

TLS : Transport Layer Security. the earlier versions used to be known as SSL ( Secure Socket Layer) SSLv3 got depreciated and TLSv1.2/1.3 are popularly used to provide encryption, authentication, Integrity and Hashing for client to server side communication.

Most of the applications communicate securely using TLS.  They will establish secure TCP connection using SSL Handshake. During the Handshake they will exchange supported versions, ciphersuites and certificates. Applications which uses TLS always uses CA certificates and Inhouse applications can communicate using self signed certificate or even with CA certificates.

HTTPS which is also known as HTTP over SSL is widely used for almost all the web services to communicate securely across the internet.

Kerberos : It is a protocol used to prove the identity for two nodes which are communicating with each other. Kerberos uses both symmetric key cryptography and assymetric key cryptography. However, symmetric key cryptography is used widely and public key cryptography is used optionally.

Authentication server which is also known as AS is used to authenticate the requesting client.  It further forwards the user credentials to key distribution center. KDC further issues to TGT ( ticket granting ticket) and it uses TGS's secret key to encrypt. User will receive a encrypted output.  

When a User Login then The client authenticates itself to the Authentication Server (AS) which forwards the username to a key distribution center (KDC). The KDC issues a ticket-granting ticket (TGT), which is time stamped and encrypts it using the ticket-granting service's (TGS) secret key and returns the encrypted result to the user's workstation. Sessions will be renewed and managed by users session manager.

4 0
3 years ago
Other questions:
  • Company A is setting up a network of mostly Windows machines. Which networking file system protocol would you recommend for maxi
    5·1 answer
  • [PROGRAMMING] A ____ signal indicates that a specific amount of time should pass before an action starts.
    13·1 answer
  • Knowing the meaning of the acronym WYSIWYG can be most helpful to you when you
    14·1 answer
  • Which writing format is also beneficial to public speaking? a. Five paragraph essay c. Conventions b. Prose d. None of these
    5·2 answers
  • Jeffrey works with a huge database of spreadsheet records each day. To organize and identify these spreadsheets, he wants to ass
    7·2 answers
  • What was the major sign that lead Professor Shiller to predict the crash of the housing market​
    6·1 answer
  • Can a spreadsheet be filtered only by one column at a time?
    11·1 answer
  • Write an assembly program that will prompt the user for 3 inputs (let’s abstractly call them a, b, and c) without a leading stri
    13·1 answer
  • 7. Which cipher is based on the clues of the physical factors, rather than the hardware or a software cryptosystem
    8·1 answer
  • Who designed the apple i computer in 1976?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!