def winning_card(cards, trump=None): Playing cards are again represented as tuples of (rank,suit) as in the cardproblems.py lecture example program. In trick taking games such as whist or bridge, four players each play one card from their hand to the trick, committing to their play in clockwise order starting from the player who plays first into the trick. The winner of the trick is determined by the following rules: 1. If one or more cards of the trump suit have been played to the trick, the trick is won by the highest ranking trump card, regardless of the other cards played. 2. If no trump cards have been played to the trick, the trick is won by the highest card of the suit of the first card played to the trick. Cards of any other suits, regardless of their rank, are powerless to win that trick. 3. Ace is the highest card in each suit. Note that the order in which the cards are played to the trick greatly affects the outcome of that trick, since the first card played in the trick determines which suits have the potential to win the trick in the first place. Return the winning card for the list of cards played to the trick.
def winning_card(cards, trump=None):
Playing cards are again represented as tuples of (rank,suit) as in the cardproblems.py
lecture example
one card from their hand to the trick, committing to their play in clockwise order starting from the
player who plays first into the trick. The winner of the trick is determined by the following rules:
1. If one or more cards of the trump suit have been played to the trick, the trick is won by the
highest ranking trump card, regardless of the other cards played.
2. If no trump cards have been played to the trick, the trick is won by the highest card of the
suit of the first card played to the trick. Cards of any other suits, regardless of their rank, are
powerless to win that trick.
3. Ace is the highest card in each suit.
Note that the order in which the cards are played to the trick greatly affects the outcome of that
trick, since the first card played in the trick determines which suits have the potential to win the
trick in the first place. Return the winning card for the list of cards played to the trick.
![cards
trump
Expected result
'diamonds'),
[('three', 'spades'), ('ace',
('jack', 'spades'), ('eight', 'spades')]
('jack',
'spades')
None
'clubs'
('two',
'clubs')
[('ace', 'diamonds'), ('ace', 'hearts'), ('ace',
'spades'), ('two',
'clubs')]
'clubs'), ('ace',
'diamonds'),
('two',
[('two',
'hearts'), ('ace', 'spades')]
('ace',
None
'clubs')](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff8493b25-a9ac-4d4b-aab2-48b43e8654fa%2F852e072e-68a6-4100-ad34-aa187a121ebe%2Fjo8i7ke_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









