Skip to content

Instantly share code, notes, and snippets.

@Joeventures
Last active September 22, 2015 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Joeventures/3de3167172423f6d6719 to your computer and use it in GitHub Desktop.
Save Joeventures/3de3167172423f6d6719 to your computer and use it in GitHub Desktop.
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
@Joeventures
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment