For some reason, I tried to make a bad Numeron
.
I have no regrets.
I referred to this article.
numeron.rb
d = []
while true
d[102, 2] = rand(0..32767).divmod(10)
d[101, 2] = rand(0..32767).divmod(10)
d[100, 2] = rand(0..32767).divmod(10)
break if d[101] != d[102] && d[102] != d[103] && d[103] != d[101]
end
puts "Please call"
while true
x200 = gets.chomp
d[111] = x200[0].to_i
d[112] = x200[1].to_i
d[113] = x200[2].to_i
d[300] = 0
d[400] = 0
d[300] += 1 if d[101] == d[111]
d[300] += 1 if d[102] == d[112]
d[300] += 1 if d[103] == d[113]
d[400] += 1 if d[101] == d[112]
d[400] += 1 if d[101] == d[113]
d[400] += 1 if d[102] == d[111]
d[400] += 1 if d[102] == d[113]
d[400] += 1 if d[103] == d[111]
d[400] += 1 if d[103] == d[112]
if d[300] == 3
puts "3 EAT"
break
else
puts "#{d[300]} EAT - #{d[400]} BITE"
end
end
rand.rb
d[100, 2] = rand(0..32767).divmod(10)
d[101] = rand(0..9)
Do not refactor with rand (0..9)
.
There is something convenient here as well.
Recommended Posts