はじめに
工場などで、向きを調整するプログラム。
実際のコード
#入力の受付
input_line = gets.chomp.split(" ")
#文字を配列になおす
collect = input_line[1].split("") #答えの文字列
testings = input_line[2].split("") #受け取った文字列
#試行回数をカウントする変数
a = 0
testings.each do
#もしも文字列が一致すれば、終了して試行回数を表示する
if collect == testings
puts a
break
else
#文字列が一致しなければ、配列を入れ替える
t = testings[0]
testings.shift()
testings.push(t)
end
a += 1
end