document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # Original problem from "Seven Languages in Seven Weeks", Day 1
  2. # Problem statement :: Write a program that picks a random number. Let a player guess the number, telling the player whether the guess is too low or too high
  3.  
  4. # this is a good illustration of the do-while looping construct in ruby
  5. # please note that this is not a documented language feature and hence its ill adviced to use it.
  6.  
  7. begin
  8.     puts "Guess a number within 1 to 10"
  9.     guess = gets.chomp.to_i
  10.     if guess>actual
  11.         puts "You have guessed a HIGHER number ... try again"
  12.     elsif guess<actual
  13.         puts "You have guessed a LOWER number ... try again"
  14.     end
  15. end until actual==guess    
  16.  
  17. puts "you have guessed the right number !!"
');