← 返回 scale.ai 的题目列表Poker Hand Validation Function with Joker Support in Python
类型:online_judge
scale.ai
Implement a Poker Hand Validation Function
In Texas Hold'em poker, each player has a number of cards. Implement a function to determine if a given poker hand meets specific poker rules.
Requirements
Define a Card class with the following attributes:
rank: The rank of the card.
suit: The suit of the card.
Provide a hand consisting of several Card objects.
The hand can contain any number of JOKER cards, which can act as any rank and suit.
Implement a method which takes 5 Card objects and, based on certain poker rules (details to be provided during the interview), determines the validity of the hand, returning a boolean value.
Example Input
[Card('JOKER', 'JOKER'), Card('2', 'Hearts'), Card('5', 'Diamonds'), Card('7', 'Clubs'), Card('10', 'Spades')]
Example Output
True
Data Scale
The method must handle all possible test cases effectively.
Optimize for performance and ensure completion within the allotted time frame.
Please develop using the Python language.
Example
Input
[Card('JOKER', 'JOKER'), Card('2', 'Hearts'), Card('5', 'Diamonds'), Card('7', 'Clubs'), Card('10', 'Spades')]