Skip to content

Instantly share code, notes, and snippets.

@inertialbit
Created November 5, 2011 19:50
Show Gist options
  • Save inertialbit/1341931 to your computer and use it in GitHub Desktop.
Save inertialbit/1341931 to your computer and use it in GitHub Desktop.
quick and dirty arithmetic cli
def ask question
print question
STDIN.gets.chomp
end
new_problem = true
10.times do
if new_problem
one = rand(10)
two = rand(10)
end
answer = ask "#{one} + #{two} = "
if answer == (one + two).to_s
print "Great Job!! `-_-`\n\n"
new_problem = true
else
print "Nope! Try again!!\n\n"
new_problem = false
redo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment