Last active
September 22, 2015 02:57
-
-
Save Joeventures/3de3167172423f6d6719 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num = rand(100) | |
guess = 0 | |
count = 0 | |
puts "Guess a number between 1 and 100!" | |
until guess == num | |
count += 1 | |
guess = gets.to_i | |
if guess > num && guess.between?(1,100) | |
puts "Your guess was too high! Try again." | |
elsif guess < num && guess.between?(1,100) | |
puts "Your guess was too low! Try again." | |
elsif guess == num | |
puts "Success in #{count} guesses! You must be smart or something." | |
else | |
puts "You did not guess a number between 1 and 100. You must be stupid. I know you're not, so try again." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I looked up the man page for grep. When reviewing the Treehouse course on navigating the shell, I saw there were ways to have the shell spit output back to you based on criteria using grep. That was pretty cool. But I have virtually no experience with regular expressions. Somehow I've always been able to avoid having to learn how to build regular expressions.
While reviewing the man page for grep didn't give me any info about regular expressions, it does tell me there are many ways of filtering out and emphasizing the parts of an output that I would like to see. The big question is whether it will be worth my while in the long run to learn regular expressions and grep.