Guess the number/With feedback (player): Difference between revisions
Guess the number/With feedback (player) (view source)
Revision as of 17:54, 13 March 2014
, 10 years ago→{{header|Ruby}}: Got rid of one variable and a typo
(→{{header|Ruby}}: Got rid of one variable and a typo) |
|||
Line 1,831:
secret = rand(r)
turns = 0
puts "Guess a number between #{r.min}
r.bsearch do |guess| # bsearch works on ranges
turns += 1
low_high = secret <=> guess # -1, 0, or 1
▲ puts "Guessing #{guess} \t #{msg}"
low_high
end
|