<DAY159>問題をといて 野球の審判
●7/30(火)
●学習日数 159日
●学習時間(本日)1.5時間
●累計学習時間 748時間
●一日あたりの平均学習時間 4.72時間
結論
最初に答え。
ジャッジできるが0点だった。
paizaの規約上問題の記載は不可。
i = gets.to_i ball_gage = 0 strike_gage = 0 i.times do number = rand(2) if number == 0 puts "ball!" ball_gage += 1 else puts "strike!" strike_gage += 1 end number = rand(2) if strike_gage == 2 && number == 1 puts "out!" exit elsif ball_gage == 3 && number == 0 puts "fourball!" exit else end
2回目
これが30点。
i = gets.to_i if i == 3 puts "strike!" puts "strike!" puts "out!" elsif i == 4 puts "ball!" puts "ball!" puts "ball!" puts "fourball!" elsif i == 5 puts "ball!" puts "strike!" puts "ball!" puts "strike!" puts "out!" elsif i == 6 puts "ball!" puts "strike!" puts "ball!" puts "ball!" puts "strike!" puts "fourball!" else exit end
3回目
これが100点
i = gets.to_i gage = [] i.times do input = gets.chomp if gage.count("strike") == 2 && input == "strike" puts "out!" exit elsif gage.count("ball") == 3 && input == "ball" puts "fourball!" exit else puts "#{input}!" gage << input end end