Skip to content

Instantly share code, notes, and snippets.

Created February 3, 2013 06:02
Show Gist options
  • Save anonymous/4700694 to your computer and use it in GitHub Desktop.
Save anonymous/4700694 to your computer and use it in GitHub Desktop.
# Chris Pine did this
num_at_start = 5 # change to 99 if you want
num_now = num_at_start
while num_now > 2
puts num_now.to_s + ' bottles of beer on the wall, ' +
num_now.to_s + ' bottles of beer!'
num_now = num_now - 1
puts 'Take one down, pass it around, ' +
num_now.to_s + ' bottles of beer on the wall!'
end
puts "2 bottles of beer on the wall, 2 bottles of beer!"
puts "Take one down, pass it around, 1 bottle of beer on the wall!"
puts "1 bottle of beer on the wall, 1 bottle of beer!"
puts "Take one down, pass it around, no more bottles of beer on the wall!"
# Below is what I did. Am I wrong?
i = 99
while i > 2
puts "#{i} bottles of beer on the wall, #{i} bottles of beer."
i = i - 1
puts "Take one down and pass it around, #{i} bottles of beer on the wall."
end
puts "2 bottles of beer on the wall, 2 bottles of beer."
puts "Take one down and pass it around, 1 bottle of beer on the wall."
puts "1 bottle of beer on the wall, 1 bottle of beer."
puts "Take one down and pass it around, no more bottles of beer on the wall."
puts "No more bottles of beer on the wall, no more bottles of beer. "
puts "Go to the store and buy some more, 99 bottles of beer on the wall."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment