Hey guys!
So I'm relatively new to all this coding thing and I am trying to get the hang out of Ruby. So I tried to do some problems and I found a lot of them quite hard. Then I just wanted to start with the easy problems, and even that fails for some reason.
The problem is called NUMGUESS (http://www.spoj.com/problems/NUMGUESS/), and I can't figure out my mistake. It's working in the command prompt like it should:
SPOJ tells me, that the timelimit is exceeded. It is a really small program, so I don't understand, why that is the case. Here is my code:
a, b = gets.split
a = a.to_i
b = b.to_i
c = rand(a..b)
guess = false
while guess == false
answer=gets.chomp
answer=answer.to_i
if answer == c
puts "WIN"
guess = true
elsif answer > c
puts "HIGH"
elsif answer < c
puts "LOW"
end
end