In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way:
在扑克牌游戏中,一手牌由五张牌构成,从低牌型到高牌型有以下几种分布:
- High Card: Highest value card.
散牌:啥都不是 - One Pair: Two cards of the same value.
一对:有2张相同点数 - Two Pairs: Two different pairs.
两对:有2对相同点数 - Three of a Kind: Three cards of the same value.
三条:有3张相同点数 - Straight: All cards are consecutive values.
顺子:所有牌点数都能连起来 - Flush: All cards of the same suit.
同花:所有牌花色相同 - Full House: Three of a kind and a pair.
葫芦(俘虏):三张相同点数加一对 - Four of a Kind: Four cards of the same value.
四条(炸弹):四张相同点数 - Straight Flush: All cards are consecutive values of same suit.
同花顺:统一花色的顺子 - Royal Flush: Ten, Jack, Queen, King, Ace, in same suit.
同花大顺:同一花色的10,J,Q,K,A
The cards are valued in the order:
牌点数从小到大:
2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.
If two players have the same ranked hands then the rank made up of the highest value wins; for example, a pair of eights beats a pair of fives (see example 1 below). But if two ranks tie, for example, both players have a pair of queens, then highest cards in each hand are compared (see example 4 below); if the highest cards tie then the next highest cards are compared, and so on.
如果两个玩家有用相同的牌型,那么组成牌型的牌点高的赢 比如,一对8比一对5大(下面例子1)。如果牌型大小平局了,就检查剩下的最高点数的牌(下面例子4)。如果最大的牌又平局了就算剩下牌的最大牌,以此类推。
Consider the following five hands dealt to two players:
Hand | Player 1 | Player 2 | Winner |
---|---|---|---|
1 | 5H 5C 6S 7S KD Pair of Fives |
2C 3S 8S 8D TD Pair of Eights |
Player 2 |
2 | 5D 8C 9S JS AC Highest card Ace |
2C 5C 7D 8S QH Highest card Queen |
Player 1 |
3 | 2D 9C AS AH AC Three Aces |
3D 6D 7D TD QD Flush with Diamonds |
Player 2 |
4 | 4D 6S 9H QH QC Pair of Queens Highest card Nine |
3D 6D 7H QD QS Pair of Queens Highest card Seven |
Player 1 |
5 | 2H 2D 4C 4D 4S Full House With Three Fours |
3C 3D 3S 9S 9D Full House with Three Threes |
Player 1 |
The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five are Player 1’s cards and the last five are Player 2’s cards. You can assume that all hands are valid (no invalid characters or repeated cards), each player’s hand is in no specific order, and in each hand there is a clear winner.
有这么个文件,里面有随机(呵呵 )的2个玩家的手牌。每行10张牌,被当个空格分隔。前5张牌是玩家1的,后5张是玩家2的。你可以假定所有的手牌都是合法的(没有无效牌符号或者重复的牌),每个玩家的牌都打乱的,每一手牌都有明确的胜利者(这句话其实已经排除很多情况了)。
How many hands does Player 1 win?
玩家1赢了多少次?