Last active
January 29, 2019 16:57
-
-
Save lukateras/e0f1e98ab0f5de5ac374dac9c81685d3 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
@accumulator = 0 | |
@beer = ''; 97.times do |n| | |
@beer << " | |
#{99-n} bottles of beer on the wall, | |
#{99-n} bottles of beer. | |
Take one down and pass it around, | |
#{98-n} bottles of beer on the wall. | |
" | |
end; @beer << " | |
2 bottles of beer on the wall, | |
2 bottles of beer. | |
Take one down and pass it around, | |
1 bottle of beer on the wall. | |
1 bottle of beer on the wall, | |
1 bottle of beer. | |
Take one down and pass it around, | |
No more bottles of beer on the wall. | |
No more bottles of beer on the wall, | |
No more bottles of beer. | |
Go to the store and buy some more, | |
99 bottles of beer on the wall. | |
" | |
def run code | |
code.scan(/[hq9+]/i).each do |operator| | |
case operator | |
when /h/i then puts "Hello, World!" | |
when /q/i then print code | |
when '9' then print @beer | |
when '+' then @accumulator += 1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment