Language Ruby
(minimal version)
| Date: | 05/18/05 |
| Author: | Anonymous |
| URL: | n/a |
| Comments: | 3 |
| Info: | n/a |
| Score: |
#Writes down an exact copy of the song on this site
99.downto(0){|b|puts "#{b==0?'No more b':"#{b} B"}ottle#{'s'if b!=1} of beer on the wall,
#{b==0?'No more':b} bottle#{'s'if b!=1} of beer.#{b==0?".. Go to the store and buy some more...\n99
bottles of beer.":"\nTake one down and pass it around, #{b-1} bottle#{'s'if b!=2} of beer on the
wall.\n\n"}"}
Download Source | Write Comment
Alternative Versions
| Version | Author | Date | Comments | Rate |
|---|---|---|---|---|
| Using continuations, singleton classes | Victor Borja | 09/15/06 | 4 | |
| object-oriented version | Mike Gertz | 04/20/05 | 2 | |
| In words | Daniel Straight | 07/10/06 | 1 | |
| shows inheritance, iterators, yield, etc | Kian Wright | 06/10/05 | 0 | |
| Readably re-opening Integer, teetotaller | Eric Budd | 01/06/08 | 0 | |
| wall-based OO version | Kevin Baird | 07/07/05 | 2 | |
| alternative version | Greg T. | 05/18/05 | 10 | |
| monkeypatch and anonymous procs | J. B. Rainsberger | 04/04/07 | 0 |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Replace the linebreaks in the code with spaces and it works correctly.
def c
"#{$n} bottle#{'s'if$n>1} of beer on the wall"end
($n=99).times{puts"#{c}, #{c[0..-13]}.
#{$n<2?"Go to the store and buy some more":"Take one down and pass it around"}, #{$n=($n-2)%99+1;c}.
"}