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: Wrong Answer

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
            flag = 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
            if one_pair == 1 and tree_card ==1:
                print('full house')
                flag = 777        
            elif one_pair == 1:
                print('one pair')
                flag = 777
            elif one_pair == 2:
                print('two pair')
                flag = 777
            elif tree_card == 1:
                print('tree card')
                flag = 777
            elif four_card == 1:
                print('four card')
                flag = 777
            straight = [[1,2,3,4,5],[2,3,4,5,6],[3,4,5,6,7],[4,5,6,7,8],[5,6,7,8,9],[6,7,8,9,10],[7,8,9,10,11],[8,9,10,11,12],[9,10,11,12,13],[10,11,12,13,1]]
            for s_list in straight:
                number.sort()
                if number[0] == 1 and number[4] == 13:
                    number.append(1)
                    number.pop(0)
                if number == s_list:
                    print('straight')
                    flag = 777
                    break
            if flag == 0:
                print('null')

       
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
while 1:
	try: p=sorted(list(map(int,input().split(','))))
	except: break
	if (p[0] == p[3]) or (p[1] == p[4]): 
		print('four card')
	elif p[0] == p[2] or p[1] == p[3] or p[2] == p[4]:
		print('three card')
	elif (p[0] == p[1] == p[2] and p[3] == p[4]) or (p[0] == [1] and p[2] == p[3] == p[4]):
		print('full house')
	elif (p[0] == p[1] and p[2] == p[3]) or (p[1] == p[2] and p[3] == p[4]):
		print('two pair')
	elif p[0] == p[1] or p[1] == p[2] or p[3] == p[4]:
		print('one pair')
	elif (p[0] == p[1]-1) and (p[1] == p[2]-1) and (p[2] == p[3]-1) and (p[3] == p[4]-1) and (p[4] == p[3]+1):
		print('straight')
	else:
		print('null')

Submission status: Wrong Answer

Solution code:
while 1:
	try: p=sorted(list(map(int,input().split(','))))
	except: break
	if (p[0] == p[3]) or (p[1] == p[4]): 
		print('four card')
	elif p[0] == p[2] or p[1] == p[3] or p[2] == p[4]:
		print('three card')
	elif (p[0] == p[1] == p[2] and p[3] == p[4]) or (p[0] == [1] and p[2] == p[3] == p[4]):
		print('full house')
	elif (p[0] == p[1] and p[2] == p[3]) or (p[1] == p[2] and p[3] == p[4]):
		print('two pair')
	elif p[0] == p[1] or p[1] == p[2] or p[3] == p[4]:
		print('one pair')
	elif (p[0] == p[1]-1) and (p[1] == p[2]-1) and (p[2] == p[3]-1) and (p[3] == p[4]-1) and  (p[4] == p[3]+1):
		print('straight')
	elif p[0] == 1 and p[1] == 10 and p[2] == 11 and p[3] == 12 and p[4] == 13:
		print('straight')
	else:
		print('null')

Submission status: Wrong Answer

Solution code:
while 1:
	try: p=sorted(list(map(int,input().split(','))))
	except: break
	if (p[0] == p[3]) or (p[1] == p[4]): 
		print('four card')
	elif p[0] == p[2] or p[1] == p[3] or p[2] == p[4]:
		print('three card')
	elif (p[0] == p[1] == p[2] and p[3] == p[4]) or (p[0] == [1] and p[2] == p[3] == p[4]):
		print('full house')
	elif (p[0] == p[1] and p[2] == p[3]) or (p[1] == p[2] and p[3] == p[4]):
		print('two pair')
	elif p[0] == p[1] or p[1] == p[2] or p[3] == p[4]:
		print('one pair')
	elif p[0] == p[1]-1 and p[1] == p[2]-1 and p[2] == p[3]-1 and p[3] == p[4]-1 and p[4] == p[3]+1:
		print('straight')
	elif p[0] == 1 and p[1] == 10 and p[2] == 11 and p[3] == 12 and p[4] == 13:
		print('straight')
	else:
		print('null')

Submission status: Wrong Answer

Solution code:
while 1:
	try: p=sorted(list(map(int,input().split(','))))
	except: break
	if (p[0] == p[3]) or (p[1] == p[4]): 
		print('four card')
	elif p[0] == p[2] or p[1] == p[3] or p[2] == p[4]:
		print('three card')
	elif (p[0] == p[1] == p[2] and p[3] == p[4]) or (p[0] == [1] and p[2] == p[3] == p[4]):
		print('full house')
	elif (p[0] == p[1] and p[2] == p[3]) or (p[1] == p[2] and p[3] == p[4]):
		print('two pair')
	elif p[0] == p[1] or p[1] == p[2] or p[2] == p[3] or p[3] == p[4]:
		print('one pair')
	elif p[0] == p[1]-1 and p[1] == p[2]-1 and p[2] == p[3]-1 and p[3] == p[4]-1 and p[4] == p[3]+1:
		print('straight')
	elif p[0] == 1 and p[1] == 10 and p[2] == 11 and p[3] == 12 and p[4] == 13:
		print('straight')
	else:
		print('null')

Submission status: Wrong Answer

Solution code:
while 1:
	try: p=sorted(list(map(int,input().split(','))))
	except: break
	if (p[0] == p[3]) or (p[1] == p[4]): 
		print('four card')
	elif p[0] == p[2] or p[1] == p[3] or p[2] == p[4]:
		print('three card')
	elif (p[0] == p[2] and p[3] == p[4]) or (p[0] == p[1] and p[2] == p[4]):
		print('full house')
	elif (p[0] == p[1] and p[2] == p[3]) or (p[1] == p[2] and p[3] == p[4]):
		print('two pair')
	elif p[0] == p[1] or p[1] == p[2] or p[2] == p[3] or p[3] == p[4]:
		print('one pair')
	elif p[0] == p[1]-1 and p[1] == p[2]-1 and p[2] == p[3]-1 and p[3] == p[4]-1 and p[4] == p[3]+1:
		print('straight')
	elif p[0] == 1 and p[1] == 10 and p[2] == 11 and p[3] == 12 and p[4] == 13:
		print('straight')
	else:
		print('null')

Submission status: Wrong Answer

Solution code:
while 1:
	try: p=sorted(list(map(int,input().split(','))))
	except: break
	if (p[0] == p[2] and p[3] == p[4]) or (p[0] == p[1] and p[2] == p[4]):
		print('full house')
	elif p[0] == p[2] or p[1] == p[3] or p[2] == p[4]:
		print('three card')
	elif (p[0] == p[1] and p[2] == p[3]) or (p[1] == p[2] and p[3] == p[4]):
		print('two pair')
	elif (p[0] == p[3]) or (p[1] == p[4]): 
		print('four card')
	elif p[0] == p[1] or p[1] == p[2] or p[2] == p[3] or p[3] == p[4]:
		print('one pair')
	elif (p[0] == p[1]-1 and p[1] == p[2]-1 and p[2] == p[3]-1 and p[3] == p[4]-1 and p[4] == p[3]+1) or (p[0] == 1 and p[1] == 10 and p[2] == 11 and p[3] == 12 and p[4] == 13):
		print('straight')
	else:
		print('null')

Submission status: Wrong Answer

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]==i:
            print("straight")
            s=True
        if not s:
            print("null")

Submission status: Wrong Answer

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 'four card'
			else:
				if nums.count(2) == 2: print 'two pair'
				elif nums.count(2) == 1: print 'one pair'
				else:
					hands2 = str(nums[12])
					for val in nums: hand2 += str(val)
					if '11111' in hands2: print 'straight'
					else: print 'null'
	except: break

Submission status: Wrong Answer

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 'four 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: Wrong Answer

Solution code:
while True:
    try:
	hand = map(int,	raw_input().split(","))
        kind = list(set(hand))
	rank =[]
	for card in kind:
	    rank.append(hand.count(kind))
      	    rank.sort()
            rank.reverse()
        if rank[0] == 4:
            print "four card"
	elif rank[0] ==	3:
            if rank[1] == 2:
		print "hull 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:
		print "straight"
	    else:
		print "null"
    except:
        break

Submission status: Wrong Answer

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 "hull 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:
from collections import Counter

ans = ["null","one pair","two pair","three card","straight","full house","four card"]
straits = [[i,i+1,i+2,i+3,i+4]for i in range(1,10)]
straits.append([1,10,11,12,13])

while(True):
    try:
        l = sorted(list(map(int,input().split(","))))
        v = sorted(list(Counter(l).values()))
        p = 0
        if v == [1,1,1,2]: p = 1
        elif v == [1,2,2]: p = 2
        elif v == [1,1,3]: p = 3
        elif l in straits: p = 4
        elif v == [2,3]: p = 5
        elif v == [1,4]: p = 6
        print(ans[p])
    except:
        break

Submission status: Accepted

Solution code:
hand = None

def find(trg, start = 0):
    count = 0
    m = -1 
    mm = 0
    for i in range(start, 5):
        if m == hand[i]:
            count += 1
        else:
            if count == trg:
                mm = i
                break
            m = hand[i]
            count = 1
    if count == trg:
        mm = i
    return mm

while True:
    try:
        hand = map( int, raw_input().split(',') ) 
    except EOFError:
        break
    hand.sort()
    if find(4): 
        print "four card"
    elif find(3) and find(2) and find(3) != find(2): 
        print "full house"
    elif (hand[1] - hand[0]) * (hand[2] - hand[1]) * (hand[3] - hand[2]) * (hand[4] - hand[3]) == 1 or (hand[0] == 1 and hand[1] == 10 and hand[2] == 11 and hand[3] == 12 and hand[4] == 13):
        print "straight"
    elif find(3):
        print "three card"
    elif find(2)*find(2,2) and find(2) != find(2, 2):
        print "two pair"
    elif find(2):
        print "one pair"
    else:
        print "null"

Submission status: Accepted

Solution code:
while True:
    try:
        cards = list(map(int, input().split(',')))
        cards.sort()

        if len(set(cards)) == 5:
            c = cards[0]
            if cards == [c, c+1, c+2, c+3, c+4]:
                print("straight")
            elif cards == [1,10,11,12,13]:
                print("straight")
            else:
                print("null")
        else:
            if len(set(cards)) == 2:
                t = cards.count(cards[0])
                if t == 1 or t == 4:
                    print("four card")
                else:
                    print("full house")
            elif len(set(cards)) == 3:
                flag = True
                i = 0
                while flag:
                    c = cards[i]
                    if cards.count(c) == 3:
                        print("three card")
                        flag = False
                    if cards.count(c) == 2:
                        print("two pair")
                        flag = False
                    i += 1
            else:
                print("one pair")
    except:
        break

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import collections

def is_four_card(cards):
  return cards.most_common(1)[0][-1] == 4
def is_full_house(cards):
  return cards.most_common(1)[0][-1] == 3 and cards.most_common(2)[-1][-1] == 2
def is_straight(cards):
  if cards[0] == 1 and cards[1:] == [10,11,12,13]: return True
  return cards == range(cards[0],cards[0]+5)
def is_three_card(cards):
  return cards.most_common(1)[0][-1] == 3
def is_two_pair(cards):
  return cards.most_common(2)[0][-1] == 2 and cards.most_common(2)[1][-1] == 2
def is_one_pair(cards):
  return cards.most_common(1)[0][-1] == 2
for s in sys.stdin:
  d = map(int,s.split(","))
  d.sort()
  dc = collections.Counter(d)
  if is_four_card(dc): print "four card" ; continue
  if is_full_house(dc): print "full house" ; continue
  if is_straight(d): print "straight" ; continue
  if is_three_card(dc): print "three card" ; continue
  if is_two_pair(dc): print "two pair" ; continue
  if is_one_pair(dc): print "one pair" ; continue
  print "null"

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

for line in f:
    c = sorted(list(map(int, line.strip().split(','))))
    if c[0] == c[3] or c[1] == c[4]:
        print('four card')
    elif (c[0] == c[2] and c[3] == c[4]) or (c[0] == c[1] and c[2] == c[4]):
        print('full house')
    elif c[0] == c[2] or c[1] == c[3] or c[2] == c[4]:
        print('three card')
    else:
        cnt = 0
        for i in range(4):
            if c[i] == c[i + 1]:
                cnt += 1
        if cnt == 2:
            print('two pair')
        elif cnt == 1:
            print('one pair')
        elif c == [1,10,11,12,13] or c[0] == c[1] - 1 == c[2] - 2 == c[3] - 3 == c[4] - 4:
            print('straight')
        else:
            print('null')

Submission status: Accepted

Solution code:
def s(n):
    sum=0
    for i in range(14):
        if n[i] == 1 : sum+=i
    if sum % 5 == 0 or sum == 47: return True
    return False

while True:
    try:
        l=map(int, input().split(","))
    except:
        break

    n=[0]*14
    for i in l:
        n[i]+=1

    if 4 in n:
        print("four card")
    elif 3 in n and 2 in n:
        print("full house")
    elif 3 in n:
        print("three card")
    elif 2 == n.count(2):
        print("two pair")
    elif 2 in n:
        print("one pair")
    elif s(n):
        print("straight")
    else:
        print("null")

Submission status: Accepted

Solution code:
def yaku(card):
    table=[0]*13
    for i in range(5):
        table[card[i]-1]+=1
    if table.count(4)!=0:
        return "four card"
    elif table.count(3)!=0:
        if table.count(2)!=0:
            return "full house"
        else:
            return "three card"
    elif table.count(2)!=0:
        if table.count(2)==2:
            return "two pair"
        else:
            return "one pair"
    else:

        if ",".join(map(str,card)) in "1,2,3,4,5,6,7,8,9,10,11,12,13" or\
           ",".join(map(str,card)) in "1,10,11,12,13":
            return "straight"
        else:
            return "null"
while True:
    try:
        card=map(int,raw_input().split(","))
        card.sort()
        print yaku(card)
    except:
        break

Submission status: Accepted

Solution code:
import sys

def heaven():
    result_dic = {}
    check_num_lis = []
    for i in range(5):
        check_num = card_lis[0]
        if not check_num in check_num_lis:
            for card in card_lis[1:]:
                if card == check_num:
                    if not card in result_dic:
                        result_dic[card] = 2
                    else:
                        result_dic[card] = result_dic[card] + 1
            check_num_lis.append(check_num)
        card_lis.append(check_num)
        del card_lis[0]
    
    suicide(result_dic)
    
def suicide(result_dic):
    result = result_dic.values()
    result.sort()
    if result == [2]:
        print 'one pair'
    elif result == [2,2]:
        print 'two pair'
    elif result == [3]:
        print 'three card'
    elif result == [4]:
        print 'four card'
    elif result == [2,3]:
        print 'full house'
    elif not result:
        card_lis.sort()
        if card_lis == [1,10,11,12,13]:
            print 'straight'
        else:
            check_num = card_lis[0]
            for card in card_lis:
                if card == check_num:
                    check_num = card + 1
                else:
                    print 'null'
                    break
            else:
                print 'straight'

for input_line in sys.stdin:
    card_lis = [int(char) for char in input_line.split(',')]
    heaven()

Submission status: Accepted

Solution code:
import sys

def is_onepair(x):
    for i in range(4):
        if x.count(x[i]) == 2:
            return True

    return False

def is_twopair(x):
    count = 0
    i = 0
    x.sort()
    while i < 5:
        if x.count(x[i]) == 2:
            i += 2
            count += 1
        else:
            i += 1
        if count == 2:
            return True

    return False

def is_threecard(x):
    for i in range(3):
        if x.count(x[i]) == 3:
            return True

    return False

def is_straight(x):
    x.sort()
    if x[0] == 1 and x[1:] == [10, 11, 12, 13]:
        return True
    for i in range(4):
        if x[i]+1 != x[i+1]:
            return False
    
    return True

def is_fullhouse(x):
    if is_threecard(x) and is_onepair(x):
        return True

    return False
    
def is_fourcard(x):
    for i in range(2):
        if x.count(x[i]) == 4:
            return True

    return False

for line in sys.stdin.readlines():
    hand = list(map(int, line.split(',')))
    if is_fourcard(hand):
        print("four card")
    elif is_fullhouse(hand):
        print("full house")
    elif is_straight(hand):
        print("straight")
    elif is_threecard(hand):
        print("three card")
    elif is_twopair(hand):
        print("two pair")
    elif is_onepair(hand):
        print("one pair")
    else:
        print("null")

Submission status: Accepted

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

while True:
	try:
		card = map(int,raw_input().split(","))
	except EOFError:
		break
	
	hand = [0,0,0,0,0,0,0,0,0,0,0,0,0]
	one  = 0
	three= 0
	four = 0
	straight = 0
	for i in range(0, 5):
		hand[card[i] - 1] += 1
		
	for i in range(0, 13):
		if hand[i] == 2:
			one += 1
		elif hand[i] == 3:
			three += 1
		elif hand[i] == 4:
			four = 1
		if hand[i] == 1:
			straight += 1
		elif straight != 5:
			straight = 0
			
	if straight == 4 and hand[0] == 1 or straight == 5:
		print "straight"
	elif four == 1:
		print "four card"
	else:
		print pair[three][one]

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin.readlines():
  l = [int(i) for i in line.split(',')]
  l.sort()
  n =sum([l.count(i) for i in l])
  if n == 17:
    print('four card')
  elif n == 13:
    print('full house')
  elif n == 11:
    print('three card')
  elif n == 9:
    print('two pair')
  elif n == 7:
    print('one pair')
  elif max(l)-min(l)==4 or (l[1] == 10 and l[0]==1):
    print('straight')
  else:
    print('null')

Submission status: Accepted

Solution code:
while 1:
    try:
        l=map(int,raw_input().split(','))
        l.sort()
        if l.count(l[2])==4:
            print 'four card'
        elif len(set(l))==2:
            print 'full house'
        elif l[0]==(l[1]-1)==(l[2]-2)==(l[3]-3)==(l[4]-4) or  (l[0]+9)==(l[1])==(l[2]-1)==(l[3]-2)==(l[4]-3):
            print 'straight'
        elif l.count(l[2])==3:
            print 'three card'
        elif len(set(l))==3:
            print 'two pair'
        elif len(set(l))==4:
            print 'one pair'
        else:
            print 'null'
    except:
        break

Submission status: Accepted

Solution code:
def function(a,b,c,d,e):
	A=[a,b,c,d,e]
	A.sort()
	#4card
	if A[0]==A[3] or A[1]==A[4]:
		print("four card")
	#Full house
	elif (A[0]==A[1] and A[2]==A[4]) or (A[0]==A[2] and A[3]==A[4]):
		print("full house")
	#three card
	elif A[0]==A[2] or A[1]==A[3] or A[2]==A[4]:
		print("three card")

	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")
	elif A[0]==A[1] or A[1]==A[2] or A[2]==A[3] or A[3]==A[4]:
		print("one pair")
	#straight A?????????
	elif A==[1,10,11,12,13]:
		print("straight")
	#straight A???????????????
	elif A[0]==A[1]-1==A[2]-2==A[3]-3==A[4]-4:
		print("straight")
	else:
		print("null")

while True:
	try:
		a,b,c,d,e=map(int,input().split(','))
		function(a,b,c,d,e)
	except EOFError:
		break

Submission status: Accepted

Solution code:
def function(a,b,c,d,e):
	A=[a,b,c,d,e]
	A.sort()
	if A[0]==A[3] or A[1]==A[4]:
		print("four card")
	elif (A[0]==A[1] and A[2]==A[4]) or (A[0]==A[2] and A[3]==A[4]):
		print("full house")
	elif A[0]==A[2] or A[1]==A[3] or A[2]==A[4]:
		print("three card")

	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")
	elif A[0]==A[1] or A[1]==A[2] or A[2]==A[3] or A[3]==A[4]:
		print("one pair")
	elif A==[1,10,11,12,13]:
		print("straight")
	elif A[0]==A[1]-1==A[2]-2==A[3]-3==A[4]-4:
		print("straight")
	else:
		print("null")

while True:
	try:
		a,b,c,d,e=map(int,input().split(','))
		function(a,b,c,d,e)
	except EOFError:
		break

Submission status: Accepted

Solution code:
import sys

def inp():
    word = []
    for line in sys.stdin:
        word = map(int, line.split(","))
        syori(sorted(word))

def syori(word):
    flag = [0,0]
    if sum(word[1:5]) == 46:
        word.append(int(word[0]))
        del word[0]

    if word == [10,11,12,13,1]:
        print "straight"
        
    else:
        for j in xrange(1,14):
            if word.count(j) == 2:
                flag[0] += 1
            elif word.count(j) == 3:
                flag[1] += 1
            elif word.count(j) == 4:
                print "four card"
                flag = [10,10]
                break
            elif word[0] + 2 == word[1] + 1 == word[2] == word[3] - 1 == word[4] - 2:
                print "straight"
                flag = [10,10]
                break

        if flag[0] == flag[1] == 1:
            print "full house"
        elif flag[0] == 1:
            print "one pair"
        elif flag[0] == 2:
            print "two pair"
        elif flag[1] == 1:
            print "three card"
        elif flag[0] < 1 or flag[1] < 1:
            print "null"

if __name__ == "__main__":
    inp()

Submission status: Accepted

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

import sys

poker = ["0", "null", "one pair", "two pair", "three card", "straight", "full house", "four card"]
for line in sys.stdin:
    H = map(int, line.split(','))
    H.sort()
    if H[0] == H[1] == H[2] == H[3] or H[1] == H[2] == H[3] == H[4]:
        print poker[7]
    elif H[0] == H[1] or H[1] == H[2] or H[2] == H[3] or H[3] == H[4]:
        if H[0] == H[1] == H[2] or H[1] == H[2] == H[3] or H[2] == H[3] == H[4]:
            if H[0] == H[1] and H[2] == H[3] == H[4] or H[0] == H[1] == H[2] and H[3] == H[4]:
                print poker[6]
            else:
                print poker[4]
        else:
            if H[0] == H[1] and H[2] == H[3] or H[0] == H[1] and H[3] == H[4] or H[1] == H[2] and H[3] == H[4]:
                print poker[3]
            else:
                print poker[2]
    else:
        if H[0] == 1 and H[4] == 13:
            H[0] += 13
            H.sort()
        if H[0]+1 == H[1] and H[1]+1 == H[2] and H[2]+1 == H[3] and H[3]+1 == H[4]:
            print poker[5]
        else:
            print poker[1]

Submission status: Accepted

Solution code:
import sys
from collections import Counter

straight = [list(range(i, i+5)) for i in range(1, 10)] + [[1,10,11,12,13]]

def hantei(hand):
	l = sorted(Counter(hand).values(), reverse=True)
	if l[0] == 4: return "four card"
	if l[0] == 3 and l[1] == 2: return "full house"
	if hand in straight: return "straight"
	if l[0] == 3: return "three card"
	if l[0] == l[1] == 2: return "two pair"
	if l[0] == 2: return "one pair"
	return "null"

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

Submission status: Accepted

Solution code:
from collections import Counter

def is_strait(_cnt):
    f = 0
    for i in range(14):
        if _cnt[(i % 13) + 1] == 1:
            f += 1
            if f == 5:
                return True
        else:
            f = 0
    return False

try:
    while 1:
        cnt = Counter(map(int,input().split(',')))
        mc = cnt.most_common(2)
        if mc[0][1] == 4:
            print('four card')
        elif mc[0][1] == 3 and mc[1][1] == 2:
            print('full house')
        elif mc[0][1] == 3:
            print('three card')
        elif mc[0][1] == mc[1][1] == 2:
            print('two pair')
        elif mc[0][1] == 2:
            print('one pair')
        elif is_strait(cnt):
            print('straight')
        else:
            print('null')
except:
    pass

Submission status: Accepted

Solution code:
while True:
    try:
        cards = list(map(int, input().split(',')))
    except:
        break
    cards.sort()
    if cards.count(cards[2]) == 4:
        print('four card')
    elif cards.count(cards[2]) == 3:
        if cards[0] == cards[1] and cards[3] == cards[4]:
            print('full house')
        else:
            print('three card')
    elif (cards[1] < cards[2] < cards[3] < cards[4]) and cards[4] - cards[1] == 3\
        and (cards[0] == cards[4] - 4 or cards[0] == cards[4] - 12):
            print('straight')
    elif (cards[0] == cards[1] and (cards[2] == cards[3] or cards[3] == cards[4]))\
        or (cards[1] == cards[2] and cards[3] == cards[4]):
        print('two pair')
    elif max(cards.count(cards[i]) for i in range(5)) == 2:
        print('one pair')
    else:
        print('null')

Submission status: Accepted

Solution code:
from collections import Counter

while True:
    try:
        card = list(map(int, input().split(",")))

    except:
        break

    counter = Counter(card)
    mc = counter.most_common()
    if len(mc) == 2:
        if mc[0][1] == 4:
            print("four card")
        else:
            print("full house")
    elif len(mc) == 3:
        if mc[0][1] == 3:
            print("three card")
        else:
            print("two pair")
    elif len(mc) == 4:
        print("one pair")
    else:
        t = sorted([mc[i][0] for i in range(len(mc))])
        if t[4]-t[3] == t[3]-t[2] == t[2]-t[1] and \
            (t[1]-t[0] or (t[0] == 1 and t[4] == 13)):
            print("straight")
        else:
            print("null")

Submission status: Accepted

Solution code:
while True:
    try:
        Size = []
        Card_Lis = list(map(int,input().split(",")))
        Card_Lis.sort()
        
        
        for tag in sorted(set(Card_Lis), key=Card_Lis.index):
            Size.append(Card_Lis.count(tag))
       
        Size.sort()

        if max(Size) == 4:
            print("four card")
        elif Size == [2,3]:
            print("full house")
        elif max(Size) == 3:
            print("three card")
        elif Size == [1,2,2]:
            print("two pair")
        elif max(Size) == 2:
            print("one pair")
        elif max(Size) == 1:
            if Card_Lis[0] == 1:
                if Card_Lis == [1,2,3,4,5] or Card_Lis == [1,10,11,12,13]:
                    print("straight")
                else:
                    print("null")
            elif Card_Lis[0] + 4 == Card_Lis[4]:
                    print("straight")
            else:
                print("null")
            
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys
from collections import Counter


class Poker(object):
    def __init__(self, cards):
        # ?????????????????????????????????????????§?????????(??????)???????????????
        self.cards = cards[:]
        self.cards.sort(reverse=True)

    def evaluate_hand(self):
        """ ???????????????????????????????????????????????????
        ????????????????????\??????????????????????????????????????§?????????????????\???????????¬????????????????????\???????????????????????¬????????????????????\?????±????????????
        - null
        - one pair
        - two pair
        - three card
        - straight
        - full house
        - four card
        """
        if (self.cards[0] == self.cards[1]+1 == self.cards[2]+2 == self.cards[3]+3 == self.cards[4]+4) or \
            (self.cards[0] == 13 and self.cards[1] == 12 and self.cards[2] == 11 and self.cards[3] == 10 and self.cards[4] ==1):
            return 'straight'
        else:
            c = Counter(self.cards)
            hand = c.most_common()  # ????????°?????????????????°????????????????????????(???: ????????????)?????????????????????????????????
            if hand[0][1] == 4:
                return 'four card'
            elif hand[0][1] == 3 and hand[1][1] == 2:
                return 'full house'
            elif hand[0][1] == 3:
                return 'three card'
            elif hand[0][1] == 2 and hand[1][1] == 2:
                return 'two pair'
            elif hand[0][1] == 2:
                return 'one pair'
            else:
                return 'null'


if __name__ == '__main__':
    # ??????????????\???
    for line in sys.stdin:
        cards = [int(x) for x in line.strip().split(',')]

        # ??????????????????
        p1 = Poker(cards)
        result = p1.evaluate_hand()

        # ???????????¨???
        print(result)