pairs = gets.split.map(&:to_i).group_by(&:itself).map{|k,v| v.size}.sort case pairs when [2, 3] puts "FULL HOUSE" when [1, 1, 3] puts "THREE CARD" when [1, 2, 2] puts "TWO PAIR" when [1, 1, 1, 2] puts "ONE PAIR" else puts "NO HAND" end