| 著作一覧 |
a = [rand(9) + 1, rand(10), rand(10)]
loop do
line = gets
if line =~ /\A(\d)(\d)(\d)\Z/
b = [$1.to_i, $2.to_i, $3.to_i]
eats = 0
bytes = 0
0.upto(2) do |i|
if b[i] == a[i]
eats += 1
else
bytes += 1 if b[i] == a[i - 1] || b[i] == a[(i + 1 > 2) ? 0 : i + 1]
end
end
puts "eats:#{eats}, bytes:#{bytes}"
exit if eats == 3
else
puts 'enter 3 digits number'
end
end
ジェズイットを見習え |