Skip to content

Instantly share code, notes, and snippets.

@coopermayne
Last active August 29, 2015 14:25
Show Gist options
  • Save coopermayne/d8bf67c2391e81c84c5d to your computer and use it in GitHub Desktop.
Save coopermayne/d8bf67c2391e81c84c5d to your computer and use it in GitHub Desktop.
your work from today
###Guessing game
```ruby
puts"pick an integer number 1...100 and keep it in your head"
puts "NO TROLLOLLOLLOLLOLLOLLOLLOing"
puts "continue... ( press enter)"
gets
top = 1000
bottom = 0
counter = 0
while true
system('clear')
numero = bottom + (top-bottom)/2
counter += 1
puts "my guess:" + numero.to_s
puts "did i guess rite
(type either lower=l,higher=h,or correct=c)"
guess=gets.chomp
if guess=='c'
system('clear')
puts "guesed it in " + counter.to_s
break
end
if guess=='l'
top = numero
end
if guess=='h'
bottom = numero
end
end
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment