def count_cards(cards): card_count = {} for card in cards: if card in card_count: card_count[card] += 1 else: card_count[card] = 1 return card_count def check_cards(cards): card_count = count_cards(cards) counts = list(card_count.values()) # "FULL HOUSE"の判定を"THREE CARD"の前に行う if counts.count(3) == 1 and counts.count(2) == 1: return "FULL HOUSE" if counts.count(3) == 1: return "THREE CARD" if counts.count(2) == 2: return "TWO PAIR" if counts.count(2) == 1: return "ONE PAIR" # "NO PAIR"を返すように修正 return "NO PAIR" input_card = input() split_card = input_card.split() cards = [int(card) for card in split_card] # リスト内包表記を使ってシンプルに result = check_cards(cards) print(result)