前提・実現したいこと
エラーに解決
発生している問題・エラーメッセージ
syntax error, unexpected `end', expecting end-of-inputとなる。
該当のソースコード
order_count = gets.to_i
x_R, x_G, x_B = gets.split(' ')
lines = readlines(chomp: true).map{|line| line.split(' ')}
order_sum = 0
order_count2 = order_count - 1
for i in 0..order_count2 do
if lines[i][0] == "R"
case lines[i][1]
when "R"
x_R += 1
when "G"
x_G += 1
when "B"
x_B += 1
when "Y"
x_R += 1
x_G += 1
when "M"
x_R +=1
x_B +=1
when "C"
x_G +=1
x_B +=1
when "W"
x_R +=1
x_G +=1
x_B +=1
end
else
case lines[i][1]
when "R"
x_R -=1
when "G"
x_G -=1
when "B"
x_B -=1
when "Y"
x_R -=1
x_G -=1
when "M"
x_R -=1
x_B -=1
when "C"
x_G -=1
x_B -=1
when "W"
x_R -=1
x_G -=1
x_B -=1
end
end
order_sum += 1
if x_R == x_G && x_R == x_B
break
end
end
if order_sum != order_count
p order_sum
else
p "no"
end

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/06/07 06:30