Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Forked from anonymous/deafgrandma.rb
Created February 15, 2009 08:44
Show Gist options
  • Save ELLIOTTCABLE/64652 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/64652 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby19 -wKu
# Here's the problem: Ruby is playing the part of a deaf grandma. If I
# don't ask her a question in upcase, she can't hear me. If I ask her any
# question in upcase, she'll respond in the same fashion unless I shout BYE
# to her. I need to shout BYE to her 3 times to escape her madness.
puts 'What is it dear?'
question = gets.chomp!
counter = 0
p 'DEBUG: before everything'
while counter < 2
p 'DEBUG: before first while'
while question != question.upcase
p 'DEBUG: in first while'
puts 'What? Speak up sonny.'
question = gets.chomp!
end
p 'DEBUG: after first while'
p 'DEBUG: before second if'
if question != 'bye'.upcase
p 'DEBUG: in second if'
puts 'No. Not since 19'+rand(10).to_s+rand(10).to_s
question = gets.chomp!
else
p 'DEBUG: in second else'
counter += 1
puts 'What was that dear?'
question = gets.chomp!
end
p 'DEBUG: after second if'
end
p 'DEBUG: after everything'
puts 'Goodbye dear.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment