[关闭]
@aloyschen 2017-10-11T15:18:51.000000Z 字数 1011 阅读 91

CodeWars 刷题总结

CodeWars


Ranking Poker Hands

A famous casino is suddenly faced with a sharp decline of their revenues. They decide to offer Texas hold'em also online. Can you help them by writing an algorithm that can rank poker hands?

Task:

Create a poker hand that has a method to compare itself to another poker hand:

  1. compare_with(self, other_hand)

A poker hand has a constructor that accepts a string containing 5 cards:

  1. PokerHand(hand)

The characteristics of the string of cards are:
A space is used as card seperator
Each card consists of two characters
The first character is the value of the card, valid characters are:

  1. 2, 3, 4, 5, 6, 7, 8, 9, T(en), J(ack), Q(ueen), K(ing), A(ce)
  2. The second character represents the suit, valid characters are:
  3. S(pades), H(earts), D(iamonds), C(lubs)

The result of your poker hand compare can be one of these 3 options:

  1. RESULT = ["Loss", "Tie", "Win"]

Apply the Texas Hold'em rules for ranking the cards.
There is no ranking for the suits.

Notes:
If you finished this kata, you might want to continue with Sortable Poker Hands.

知识点

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注