Problem:


ポーカー

ポーカーの手札データを読み込んで、それぞれについてその役を出力するプログラムを作成してください。ただし、この問題では、以下のルールに従います。

ポーカーはトランプ 5 枚で行う競技です。

同じ数字のカードは 5 枚以上ありません。

ジョーカーは無いものとします。

以下のポーカーの役だけを考えるものとします。(番号が大きいほど役が高くなります。)

役なし(以下に挙げるどれにも当てはまらない)

ワンペア（2 枚の同じ数字のカードが1 組ある）

ツーペア（2 枚の同じ数字のカードが2 組ある）

スリーカード（3 枚の同じ数字のカードが1 組ある）

ストレート（5 枚のカードの数字が連続している）

ただし、A を含むストレートの場合、A で終わる並びもストレートとします。つまり、A を含むストレート
は、A 2 3 4 5 　と　10 J Q K A 　の２種類です。J Q K A 2 などのように、A をまたぐ並び
はストレートではありません。（この場合、「役なし」になります）。

フルハウス（3 枚の同じ数字のカードが1 組と、残りの2 枚が同じ数字のカード）

フォーカード（4 枚の同じ数字のカードが1 組ある）

Input

入力は複数のデータセットからなります。各データセットは以下の形式で与えられます。

手札1,手札2,手札3,手札4,手札5

手札は、トランプのJ(ジャック) を11、Q(クイーン) を12、K(キング) を13、A（エース）を 1、その他はそれぞれの数字で表すこととします。

データセットの数は 50 を超えません。

Output

データセットごとに、手札によってできる最も高い役をひとつ出力してください。役の表記については出力例に従ってください。

Sample Input

1,2,3,4,1
2,3,2,3,12
12,13,11,12,12
7,6,7,6,7
3,3,2,3,3
6,7,8,9,10
11,12,10,1,13
11,12,13,1,2

Output for the Sample Input

one pair
two pair
three card
full house
four card
straight
straight
null

3 3 2 3 3 という手札であったときは、two pair ではなく four card です。



Sample input:
1,2,3,4,1
2,3,2,3,12
12,13,11,12,12
7,6,7,6,7
3,3,2,3,3
6,7,8,9,10
11,12,10,1,13
11,12,13,1,2


Sample output:
one pair
two pair
three card
full house
four card
straight
straight
null

Submission status: Accepted

Solution code:
def hand(card):
    m = 0
    n = [0]*13
    val = 0
    for i in range(13):
        n[i] = card.count(str(i+1))
    for i in range(13):
        if n[i] == 4:
            return 'four card'
    for i in range(13):
        if n[i] == 3:
            for j in range(13):
                if n[j] == 2:
                    return 'full house'
            return 'three card'

    for i in range(13):
        if n[i] == 2:
            for j in range(i+1,13):
                if n[j] == 2:
                    return 'two pair'
            return 'one pair'
    for i in range(len(card)):
        card[i] = int(card[i])
    card.sort()
    
    if card == [1,10,11,12,13]:
        return 'straight'
    for i in range(4):
        if card[4-i] - card[4-i-1] != 1:
            return 'null'
    return 'straight'

while True:
    try:
        card = input().split(',')
        print(hand(card))
            
    except:
        break

Submission status: Accepted

Solution code:
def isstraight(cs):
    if 1 in cs:
        if cs==[1,2,3,4,5] or cs==[1,10,11,12,13]:
            return True
        else:
            return False
    else:
        for i in range(len(cs)-1):
            if cs[i+1]!=cs[i]+1:
                return False
        return True

while 1:
    try:
        c= list(map(int, input().split(',')))
    except:
        break
    l= [c.count(i) for i in set(c)]
    ans= {7: "four card", 6: "full house", 5: "straight", 4: "three card", 3: "two pair", 2: "one pair", 1: "null"}
    if len(set(c))==5:
        v= 5 if isstraight(sorted(c)) else 1
    else:
        v= 7 if 4 in l else(6 if 3 in l and 2 in l else(4 if 3 in l else(3 if l.count(2)==2 else 2)))
    print(ans[v])

Submission status: Accepted

Solution code:
while 1:
    try:n=sorted(map(int,input().split(',')))
    except:break
    c=sum(n.count(x) for x in n)
    if c==17:c=3
    elif c in [13,11,9,7]:c-=5
    elif max(n)-min(n)==4 or (n[1] == 10 and n[0]==1):c=1
    else:c=0
    print(['null','straight','one pair','four card','two pair','','three card','','full house'][c])

Submission status: Accepted

Solution code:
import re
chars = {'10':'D', '11':'J', '12':'Q', '13':'K'}
while True:
    try:
        f = sorted(map(int, input().strip().split(',')))
        g = list(map(str,f.copy()))
        for i in chars.keys():
            while i in g:
                g[g.index(i)] = chars[i]
        h = ''.join(g)
        if re.search(r'(.)\1\1\1', h):
            print('four card')
        elif re.search(r'(.)\1\1(.)\2', h) or re.search(r'(.)\1(.)\2\2', h):
            print('full house')
        elif (f[1]==f[0]+1 and f[2]==f[0]+2 and f[3]==f[0]+3 and f[4]==f[0]+4) or h=='1DJQK':
            print('straight')
        elif re.search(r'(.)\1\1', h):
            print('three card')
        elif  re.search(r'(.)\1.?(.)\2', h):
            print('two pair')
        elif  re.search(r'(.)\1', h):
            print('one pair')
        else:
            print('null')

    except EOFError:
        break

Submission status: Accepted

Solution code:
N = 13
while True:
    try:
        A = list(map(int,input().split(',')))
    except EOFError:
        break
    flag = False
    for i in range(1,N + 1):
        if A.count(i) == 4:
            flag = True
            print('four card')
            break
    if flag:
        continue
    for i in range(1,N + 1):
        for j in range(1,N + 1):
            if i == j:
                continue
            if A.count(i) == 3 and A.count(j) == 2:
                flag = True
                print('full house')
                break
        if flag:
            break
    if flag:
        continue
    for i in range(1,11):
        cnt = 0
        for j in range(0,5):
            if i + j == 14:
                cnt += A.count(1) > 0
            else:
                cnt += A.count(i + j) > 0
        if cnt == 5:
            flag = True
            print('straight')
            break
    if flag:
        continue
    for i in range(1,N + 1):
        if A.count(i) == 3:
            flag = True
            print('three card')
            break
    if flag:
        continue
    for i in range(1,N + 1):
        for j in range(1,N + 1):
            if i == j:
                continue
            if A.count(i) == 2 and A.count(j) == 2:
                flag = True
                print('two pair')
                break
        if flag:
            break
    if flag:
        continue
    for i in range(1,N + 1):
        if A.count(i) == 2:
            flag = True
            print('one pair')
            break
    if flag:
        continue
    print('null')

Submission status: Accepted

Solution code:
while True:
    try:
        rawhand = input().split(",")
        hand = [0]*14
        for card in rawhand:
            if card =="A" : hand[1] += 1
            elif card =="J" : hand[11] += 1
            elif card =="Q" : hand[12] += 1
            elif card =="K" : hand[13] += 1
            else: hand[int(card)] += 1
        pairs = 0
        three = False
        four = False
        minone = 0
        for i in range(14):
            ranks = hand[i]
            if ranks == 1 and minone == 0: minone = i
            elif ranks == 2: pairs += 1
            elif ranks == 3: three = True
            elif ranks == 4: four = True; break

        straight = hand[minone]==1 and hand[minone+1]==1 and hand[minone+2]==1 and hand[minone+3]==1 and hand[minone+4]==1
        straight = straight or (hand[1]==1 and hand[10]==1 and hand[11]==1 and hand[12]==1 and hand[13]==1)

        if four: print("four card")
        elif three and pairs == 1: print("full house")
        elif straight: print("straight")
        elif three: print("three card")
        elif pairs == 2: print("two pair")
        elif pairs == 1: print("one pair")
        else: print("null")
    except EOFError:
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os

for s in sys.stdin:
    A = list(map(int, s.split(',')))
    A.sort()
    #print(A)

    if (A[0] == A[1] == A[2] == A[3]) or (A[1] == A[2] == A[3] == A[4]):
        print('four card')

    # full house
    elif (A[0] == A[1] == A[2]) and (A[3] == A[4]):
        print('full house')
    elif (A[0] == A[1]) and (A[2] == A[3] == A[4]):
        print('full house')

    # straight
    elif A[0] == A[1] - 1 == A[2] - 2 == A[3] - 3 == A[4] - 4:
        print('straight')
    elif A[1] == 10 and A[2] == 11 and A[3] == 12 and A[4] == 13 and A[0] == 1:
        print('straight')

    # three card
    elif (A[0] == A[1] == A[2]) or (A[1] == A[2] == A[3]) or (A[2] == A[3] == A[4]):
        print('three card')

    # two pair
    elif ((A[0] == A[1]) and (A[2] == A[3])) or ((A[0] == A[1]) and (A[3] == A[4])) or ((A[1] == A[2]) and (A[3] == A[4])):
        print('two pair')

    # one pair
    elif (A[0] == A[1]) or (A[1] == A[2]) or (A[2] == A[3]) or (A[3] == A[4]):
        print('one pair')

    else:
        print('null')

Submission status: Accepted

Solution code:
while True : 
    try :
        temp = [int(_) for _ in input().split(',')]
        length = len(set(temp))
        
        if length == 2 :
            if temp.count(temp[0]) == 1 or temp.count(temp[0]) == 4 : print('four card')
            else : print('full house')
        elif length == 3 :
            for _ in set(temp) :
                if temp.count(_) == 2 :
                    print('two pair')
                    break
                elif temp.count(_) == 3 :
                    print('three card')
                    break
        elif length == 4 : print('one pair')
        else : 
            temp.sort(reverse = True)
            test = [(temp[0] - _) for _ in range(5)]
            if temp == test or temp == [13, 12, 11, 10, 1] : print('straight')
            else : print('null')
    except :
        break

Submission status: Accepted

Solution code:
# Aizu Problem 0038: Poker Hand
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def is_straight(hand):
    if hand == [1, 10, 11, 12, 13]:
        return True
    m = min(hand)
    if hand == list(range(m, m + 5)):
        return True
    return False


def poker_hand(hand):
    hand = sorted(hand)
    counts = {}
    for card in hand:
        counts[card] = counts.get(card, 0) + 1
    counts = sorted(list(counts.values()))
    if counts == [1, 4]:
        return "four card"
    elif counts == [2, 3]:
        return "full house"
    elif is_straight(hand):
        return "straight"
    elif counts == [1, 1, 3]:
        return "three card"
    elif counts == [1, 2, 2]:
        return "two pair"
    elif counts == [1, 1, 1, 2]:
        return "one pair"
    else:
        return "null"


while True:
    try:
        hand = [int(_) for _ in input().split(',')]
    except EOFError:
        break
    print(poker_hand(hand))

Submission status: Accepted

Solution code:
import sys


def checkPairs(cards):
  result = {}
  for card in cards:
    if cards.count(card) >= 2:
      result.update({card: cards.count(card)})
  keysNum = len(result.keys())
  values = list(result.values())
  if keysNum == 0:
    return "null"
  elif keysNum == 2:
    if values.count(3) > 0:
      return "full house"
    else:
      return "two pair"
  else:
    if values.count(4) > 0:
      return "four card"
    elif values.count(3) > 0:
      return "three card"
    else:
      return "one pair"


def checkStraight(cards):
  if cards.count(1) > 0:
    if cards[1] == 10 and cards[2] == 11 and cards[3] == 12 and cards[4] == 13:
      return True
  if cards[0] == cards[1] - 1 and cards[1] == cards[2] - 1 and cards[2] == cards[3] - 1 and cards[3] == cards[4] - 1:
    return True
  else:
    return False


for line in sys.stdin:
  try:
    cards = [int(i) for i in line.split(',')]
    cards.sort()
    result = checkPairs(cards)
    if result == "full house" or result == "four card":
      print(result)
    else:
      print("straight" if checkStraight(cards) else result)
  except:
    break

Submission status: Accepted

Solution code:
from itertools import permutations
import sys
import os

def inini(_card):
    for i in range(len(_card)):
        _card[i] = 0


def main():
    for s in sys.stdin:
            card = 14*[0]
            inini(card)
            number = list(map(int,s.split(',')))
            for v in number:
                card[v] += 1
            one_pair = 0
            tree_card = 0
            four_card = 0
            for value in sorted(set(number),key=number.index):
                if card[value] == 2:
                    one_pair += 1
                elif card[value] == 3:
                    tree_card += 1
                elif card[value] == 4:
                    four_card += 1
            number.sort()
            if one_pair == 1 and tree_card ==1:
                print('full house')       
            elif one_pair == 1:
                print('one pair') 
            elif one_pair == 2:
                print('two pair')
            elif tree_card == 1:
                print('three card')   
            elif four_card == 1:
                print('four card')
            elif number[0] == number[1]-1 == number[2]-2 == number[3]-3 == number[4]-4:
                print('straight')
            elif number[0] == 1 and number[1] == 10 and number[2] == 11 and number[3] == 12 and number[4] == 13:
                print('straight')
            else:
                print('null')
                
            

       
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
straight = [[i for i in range(j,j + 5)] for j in range(1,10)]
straight.append([1,10,11,12,13])
while True:
    try:
        h = list(map(int, input().split(",")))
        h_s = sorted(h)
        p = []
        for i in range(4):
            if h_s[i] != h_s[i + 1]:
                p.append(i)
        if len(p) == 1:
            if p[0] == 0 or p[0] == 3:
                print("four card")
            else:
                print("full house")
        elif h_s in straight:
            print("straight")
        elif len(p) == 2:
            if p[0] == 1 or p == [0,2]:
                print("two pair")
            else:
                print("three card")
        elif len(p) == 3:
            print("one pair")
        else:
            print("null")
    except:
        break

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())

for l in range(len(N)):
    table = [0 for i in range(15)]
    cards = [int(i) for i in N[l].split(",")]
    for i in range(5):
        table[cards[i]] += 1

    two,three,four,ren = 0,0,0,0
    for i in range(15):
        if table[i] == 2:
            two += 1
        elif table[i] == 3:
            three += 1
        elif table[i] == 4:
            four += 1

    for i in range(14):
        if table[i] == 1 and table[i+1] == 1:
            ren += 1
    if table[10] == 1 and table[11] == 1 and table[12] == 1 and table[13] == 1 and table[1] == 1:
        ren = 4
    ans = "null"
    if four == 1:
        ans = "four card"
    elif two == 1 and three == 1:
        ans = "full house"
    elif ren == 4:
        ans = "straight"
    elif three == 1:
        ans = "three card"
    elif two == 2:
        ans = "two pair"
    elif two == 1:
        ans = "one pair"
    print(ans)

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 e=list(map(int,e.split(',')))
 c=[e.count(i+1)for i in range(13)];d=c+c
 if 4 in c:s='four card'
 elif 3 in c:
  if 2 in c:s='full house'
  else:s='three card'
 elif 2 in c:
  if c.count(2)-1:s='two pair'
  else:s='one pair'
 elif sum([1]*5==d[i:i+5]for i in range(10)):s='straight'
 else:s='null'
 print(s)

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 e=sorted(map(int,e.split(',')))
 n=sum(e.count(s)for s in e)-5
 print([['null','straight'][e[4]-e[0]==4 or e[0]*10==e[1]],'one pair','two pair','three card','full house',0,'four card'][n//2])

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 e=sorted(map(int,e.split(',')))
 print([['null','straight'][e[4]-e[0]==4 or e[0]*10==e[1]],'one pair','two pair','three card','full house',0,'four card'][sum(e.count(s)for s in e)//2-2])

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 e=sorted(map(int,e.split(',')))
 print([['null','straight'][e[0]*10==e[1]or e[4]-e[0]==4],'one pair','two pair','three card','full house',0,'four card'][sum(e.count(s)for s in e)//2-2])

Submission status: Accepted

Solution code:
import sys
for e in sys.stdin:
 e=sorted(map(int,e.split(',')))
 print([['null','straight'][e[0]*9<e[1]or e[4]-e[0]<5],'one pair','two pair','three card','full house',0,'four card'][sum(e.count(s)for s in e)//2-2])

Submission status: Accepted

Solution code:
from collections import Counter

#カードを引数に取って答えを出力する
def put_ans(cards):
  cards.sort()

  #10 ~ Aのストレート
  if cards == [1, 10, 11, 12, 13]:
    print("straight")
    return

  #それ以外のストレート
  for i in range(1,len(cards)):
    if cards[i] - cards[i - 1] != 1:
      break
  else:
    print("straight")
    return
  
  #result...カードの枚数の降順リスト
  result = [t[1] for t in Counter(cards).most_common()]

  if result == [1,1,1,1,1]:
    print("null")
  if result == [2,1,1,1]:
    print("one pair")
  if result == [2,2,1]:
    print("two pair")
  if result == [3,1,1]:
    print("three card")
  if result == [3, 2]:
    print("full house")
  if result == [4, 1]:
    print("four card")

def main():
  while True:
    try:
      cards = list(map(int, input().split(",")))
      put_ans(cards)
  
    except EOFError:
      break

main()

Submission status: Accepted

Solution code:
from collections import Counter
import sys

for t in sys.stdin:
    l=sorted(map(int,t[:-1].split(",")))
    s=False
    p1=Counter(l)
    p2=Counter(p1.values())

    if 3 in p2 and 2 in p2:
        print("full house")
    elif 2 in p2:
        if p2[2]==1:
            print("one pair")
        elif p2[2]==2:
            print("two pair")
    elif 3 in p2:
        print("three card")
    elif 4 in p2:
        print("four card")
    else:
        for i in range(1,10):
            if list(range(i,i+5))==l:
                print("straight")
                s=True
                break
        if [1,10,11,12,13]==l:
            print("straight")
            s=True
        if not s:
            print("null")

Submission status: Accepted

Solution code:
# AOJ 0038: Poker Hand
# Python3 2018.6.27 bal4u

def judge(card, cnt):
	nmax = cnt[0][1]
	if nmax == 4: return "four card"
	if nmax == 3: return "full house" if cnt[1][1] == 2 else "three card"
	if nmax == 2: return "two pair" if cnt[1][1] == 2 else "one pair"
	if (card[0] == 1 and list(range(10, 14)) == card[1:]) \
		or list(range(card[0], card[0]+5)) == card: return "straight"
	return "null"

import collections
while True:
	try: card = list(map(int, input().split(',')))
	except: break
	cnt = collections.Counter(card)
	print(judge(sorted(card), sorted(cnt.items(), key=lambda x: -x[1])))

Submission status: Accepted

Solution code:
try:
    while True:
        a: list = sorted(map(int, input().split(",")))

        if a.count(a[0]) == 4 or a.count(a[1]) == 4:
            print("four card")
        elif len(set(a)) == 2:
            print("full house")
        elif (a[0]+4 == a[1]+3 == a[2]+2 == a[3]+1 == a[4] or
              a == [1, 10, 11, 12, 13]):
            print("straight")
        elif max(a.count(a[0]), a.count(a[1]), a.count(a[2])) == 3:
            print("three card")
        elif len(set(a)) == 3:
            print("two pair")
        elif len(set(a)) == 4:
            print("one pair")
        else:
            print("null")

except EOFError:
    exit()

Submission status: Accepted

Solution code:
import sys
HAND=["null","one pair","two pair","three card","straight","full house","four card"]
for line in sys.stdin.readlines():
    cards=sorted(map(int,line.strip().split(",")))
    switch=len(set(cards))
    ma=cards.count(max(cards,key=lambda c:cards.count(c)))
    if switch==4:print HAND[1]
    elif switch==3:
        if ma==2:print HAND[2]
        else:print HAND[3]
    elif switch==2:
        if ma==4:print HAND[6]
        else:print HAND[5]
    else:
        if cards==[1,10,11,12,13] or len(set([cards[i+1]-cards[i] for i in xrange(4)]))==1:print HAND[4]
        else:print HAND[0]

Submission status: Accepted

Solution code:
import sys
HAND=["null","one pair","two pair","three card","straight","full house","four card"]
for line in sys.stdin.readlines():
    cards=sorted(map(int,line.strip().split(",")))
    switch=len(set(cards))
    ma=max([cards.count(i) for i in cards])
    if switch==4:print HAND[1]
    elif switch==3:
        if ma==2:print HAND[2]
        else:print HAND[3]
    elif switch==2:
        if ma==4:print HAND[6]
        else:print HAND[5]
    else:
        if cards==[1,10,11,12,13] or len(set([cards[i+1]-cards[i] for i in xrange(4)]))==1:print HAND[4]
        else:print HAND[0]

Submission status: Accepted

Solution code:
import sys
HAND=["null","one pair","two pair","three card","straight","full house","four card"]
for line in sys.stdin.readlines():
    cards=sorted(map(int,line.strip().split(",")))
    switch=len(set(cards))
    ma=max([cards.count(i) for i in cards])
    if switch==4:print HAND[1]
    elif switch==3:
        if ma==2:print HAND[2]
        else:print HAND[3]
    elif switch==2:
        if ma==4:print HAND[6]
        else:print HAND[5]
    else:
        if cards==[1,10,11,12,13] or [cards[i+1]-cards[i] for i in xrange(4)]==[1,1,1,1]:print HAND[4]
        else:print HAND[0]

Submission status: Accepted

Solution code:
HANDS = {
    'one pair': [1,1,1,2],
    'two pair': [1,2,2],
    'three card': [1,1,3],
    'four card': [1,4],
    'full house': [2,3],
}

def check(key, value):
    for (k, v) in HANDS.iteritems():
        if value == v:
            return k
    if key[-1] - key[0] == 4 or key == [1, 10, 11, 12, 13]:
        return 'straight'
    else:
        return 'null'

while True:
    try:
        cards = map(int, raw_input().split(','))
        m = {}
        for n in cards:
            if m.has_key(n):
                m[n] += 1
            else:
                m[n] = 1
        print check(sorted(m.keys()), sorted(m.values()))
    except EOFError:
        break

Submission status: Accepted

Solution code:
while True:
	try:
		nums = [0 for x in xrange(13)]
		hands = map(int,raw_input().split(','))
		for val in hands: nums[val-1] += 1
		if 4 in nums: print 'four card'
		else:
			if 3 in nums:
				if 2 in nums: print 'full house'
				else: print 'three card'
			else:
				if nums.count(2) == 2: print 'two pair'
				elif nums.count(2) == 1: print 'one pair'
				else:
					hands2 = ''
					for val in xrange(14): hands2 += str(nums[val%13])
					if '11111' in hands2: print 'straight'
					else: print 'null'
	except: break

Submission status: Accepted

Solution code:

import sys


def solv(hand):
    if four_card(hand):
        return "four card"
    elif full_house(hand):
        return "full house"
    elif straight(hand):
        return "straight"
    elif three_card(hand):
        return "three card"
    elif two_pair(hand):
        return "two pair"
    elif one_pair(hand):
        return "one pair"
    else:
        return "null"

def four_card(hand):
    s = set(hand)
    if len(s) == 2:
        for c in s:
            if count(hand, c) == 4:
                return True
    else:
        return False

def full_house(hand):
    s = set(hand)
    if len(s) == 2:
        for c in s:
            if count(hand, c) == 3:
                return True
    else:
        return False

def straight(hand):
    hand.sort()
    if difference_one(hand):
        return True
    elif difference_one(change_ace(hand)):
        return True
    else:
        return False

def three_card(hand):
    s = set(hand)
    if len(s) == 3:
        for c in s:
            if count(hand, c) == 3:
                return True
    else:
        return False

def two_pair(hand):
    s = set(hand)
    return len(s) == 3

def one_pair(hand):
    s = set(hand)
    return len(s) == 4


def count(hand, c):
    return len(filter(lambda x: x == c, hand))

def difference_one(hand):
    r = []
    d = reduce(lambda x, y: (add_list(x[0], y-x[1]), y), hand, (r,0))
    d[0].pop(0)
    return d[0] == [1,1,1,1]

def add_list(lis, x):
    lis.append(x)
    return lis

def change_ace(hand):
    r = []
    for c in hand:
        if c == 1:
            r.append(14)
        else:
            r.append(c)
    r.sort()
    return r



for line in sys.stdin:
    hand = map(int, line.split(','))
    print solv(hand)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from sys import stdin
from collections import Counter


for line in stdin:
    L = sorted([int(s) for s in line.split(',')])
    cnt = Counter(L)
    length, num = len(cnt), cnt.most_common(1)[0][1]
    if length == 4 and num == 2:
        print('one pair')
    elif length == 3 and num == 2:
        print('two pair')
    elif length == 3 and num == 3:
        print('three card')
    elif length == 2 and num == 3:
        print('full house')
    elif length == 2 and num == 4:
        print('four card')
    elif L[0] == L[1]-1 == L[2]-2 == L[3]-3 == L[4]-4:
        print('straight')
    elif L[0] == 1 and L[1]-1 == L[2]-2 == L[3]-3 == L[4]-4:
        print('straight')
    else:
        print('null')

Submission status: Accepted

Solution code:
import sys

def straight(cards):
    aa = range(1,5)
    if cards == [1, 10, 11, 12, 13]:
        return True
    for i in range(1, 10):
        if cards == range(i, i+5):
            return True
    return False

for s in sys.stdin.read().rstrip().split('\n'):
    cards = sorted(map(int, s.split(',')))
    c = [0]*13
    for card in cards:
        c[card-1] += 1
    if 4 in c:
        print 'four card'
    elif (3 in c) and (2 in c):
        print 'full house'
    elif straight(cards):
        print 'straight'
    elif 3 in c:
        print 'three card'
    elif c.count(2) == 2:
        print 'two pair'
    elif c.count(2) == 1:
        print 'one pair'
    else:
        print 'null'

Submission status: Accepted

Solution code:
def readdata():
    x = []
    try:
        while True:
            x.append(map(int,raw_input().split(",")))
    except: return x

def checkhand2(hand):
    tmp = [(e+11)%13 for e in hand]
    x1=sorted(list(set(tmp)))
    x2=[]
    for e in x1:
        x2.append(tmp.count(e))
    return x1,x2

def isstraight(x1):
    if x1==[0,1,2,3,12]: return True
    e = x1[0]
    if x1==range(e,e+5): return True
    else: return False

def checkhand(hand):
    x1,x2 = checkhand2(hand)
    x2 = sorted(x2)
    prize = 0
    if x2==[1,1,1,1,1]:
        if isstraight(x1): prize = 4
        else: prize = 0
    elif x2==[1,1,1,2]: prize = 1
    elif x2==[1,2,2]: prize = 2
    elif x2==[1,1,3]: prize = 3
    elif x2==[2,3]: prize = 5
    elif x2==[1,4]: prize = 6
    return prize

values=[2,3,4,5,6,7,8,9,10,11,12,13,1]
prize=["null","one pair","two pair","three card",
        "straight","full house","four card"]

hands = readdata()
for e in hands:
    print prize[checkhand(e)]

Submission status: Accepted

Solution code:
prize=["null","one pair","two pair","three card",
        "straight","full house","four card"]

try:
    while True:
        hand = map(int,raw_input().split(","))
        x = sorted(list(set(hand)))
        a = len(x)
        b = max([hand.count(e) for e in x])
        if b==4: p=6
        elif b==3:
            if a==2: p=5
            else: p=3
        elif b==2:
            if a==3: p=2
            else: p=1
        elif b==1:
            e = x[0]
            if x==[1,10,11,12,13] or x==range(e,e+5): p=4
            else: p=0
        print prize[p]
except:
    pass

Submission status: Accepted

Solution code:
from sys import stdin
prize=["null","one pair","two pair","three card",
        "straight","full house","four card"]

for line in stdin:
    hand = map(int,line.split(","))
    x = sorted(list(set(hand)))
    a = len(x)
    b = max([hand.count(e) for e in x])
    if b==4: p=6
    elif b==3:
        if a==2: p=5
        else: p=3
    elif b==2:
        if a==3: p=2
        else: p=1
    elif b==1:
        e = x[0]
        if x==[1,10,11,12,13] or x==range(e,e+5): p=4
        else: p=0
    print prize[p]

Submission status: Accepted

Solution code:
while True:
    try:
        hand = map(int, raw_input().split(","))
        kind = list(set(hand))
        rank =[]
        for card in kind:
            rank.append(hand.count(card))
            rank.sort()
            rank.reverse()
        if rank[0] == 4:
            print "four card"
        elif rank[0] == 3:
            if rank[1] == 2:
                print "full house"
            else:
                print "three card"
        elif rank[0] == 2:
            if rank[1] == 2:
                print "two pair"
            else:
                print "one pair"
        else:
            hand.sort()
            if hand[4] - hand[0] == 4 or (hand[0] == 1 and hand[1] == 10):
                print "straight"
            else:
                print "null"
    except:
        break

Submission status: Accepted

Solution code:
while True:
      try:
            hand = sorted(map(int, raw_input().split(",")))
            kind = len(set(hand))
            ma = max([hand.count(i) for i in hand])
            if kind == 4:
                  print "one pair"
            elif kind == 3:
                  if ma == 2:
                        print "two pair"
                  else:
                        print "three card"
            elif kind == 2:
                  if ma==4:
                        print "four card"
                  else:
                        print "full house"
            else:
                  if hand==[1,10,11,12,13] or hand[4] - hand[0] == 4:
                        print "straight"
                  else:
                        print "null"
      except:
            break

Submission status: Accepted

Solution code:
try:
    while True:
        a = sorted(map(int, raw_input().split(',')))
        if a.count(a[2]) == 4:
            print 'four card'
        elif a.count(a[1]) + a.count(a[-2]) == 5:
            print 'full house'
        elif a == range(a[0], a[0] + 5) or a == [1, 10, 11, 12, 13]:
            print 'straight'
        elif a.count(a[2]) == 3:
            print 'three card'
        elif a.count(a[1]) == 2 and a.count(a[-2]) == 2:
            print 'two pair'
        elif len(set(a)) == 4:
            print 'one pair'
        else:
            print 'null'
except EOFError:
    pass

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin:
  hand = sorted(map(int, s.split(',')))
  kind = len(set(hand))
  ma = max([hand.count(i) for i in hand])
  
  ans = 'null'
  if kind == 4:
    ans = 'one pair'
  elif kind == 3:
    if ma == 2:
      ans = 'two pair'
    else:
      ans = 'three card'
  elif kind == 2:
    if ma==4:
      ans = 'four card'
    else:
      ans = 'full house'
  else:
    if hand == [1,10,11,12,13] or (hand[4] - hand[0]) == 4:
      ans = 'straight'
  print ans

Submission status: Accepted

Solution code:
from collections import Counter

while 1:
    try:
        hand = map(int, raw_input().split(','))
    except EOFError:
        break
    count = Counter(hand).most_common()

    ret = ''
    if count[0][1] >= 4:
        ret = 'four card'
    elif len(count) >= 2 and count[0][1] == 3 and count[1][1] == 2:
        ret = 'full house'
    elif len(count) == 5:
        sort_hand = sorted(hand)
        for i in xrange(4):
            if sort_hand[i] + 1 != sort_hand[i + 1]:
                break
        else:
            ret = 'straight'
        if sort_hand == [1, 10, 11, 12, 13]:
            ret = 'straight'
    elif len(count) == 3 and count[0][1] == 3:
        ret = 'three card'
    elif len(count) == 3 and count[0][1] == count[1][1] == 2:
        ret = 'two pair'
    elif len(count) == 4:
        ret = 'one pair'
    if ret:
        print ret
    else:
        print 'null'