cards = gets.chomp # 文字列の入力を受け付ける .split # 文字列を空白文字で分割して配列にする .map { _1.to_i } # 配列の要素を数値にする count0 = cards.count(cards[0]) count1 = cards.count(cards[1]) count2 = cards.count(cards[2]) count3 = cards.count(cards[3]) count4 = cards.count(cards[4]) counts = [count0, count1, count2, count3, count4] if counts.include?(3) if counts.include?(2) puts "FULL HOUSE" else puts "THREE CARD" end elsif counts.include?(2) if counts.count(2) == 4 puts "TWO PAIR" else puts "ONE PAIR" end else puts "NO HAND" end