def hantei(hands) sum=0 hands.values.each do |hand| sum = hand + sum end case sum when 0,1,3,4,6 kekka='あいこ。もう一度' when 2 if hands.has_value?(2) then kekka="パーで#{hands.index(2)}の勝ち" else kekka="グーで#{hands.index(0)}の勝ち" end when 5 kekka="チョキで#{hands.index(1)}の勝ち" end yobina=['グー','チョキ','パー'] hands.each do |name,hand| puts "#{name}:#{yobina[hand]}" end puts kekka end