Language Ruby
(minimal version)
Date: | 05/18/05 |
Author: | Anonymous |
URL: | n/a |
Comments: | 3 |
Info: | n/a |
Score: | (3.02 in 116 votes) |
#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 | 9 | |
object-oriented version | Mike Gertz | 04/20/05 | 2 | |
shows inheritance, iterators, yield, etc | Kian Wright | 06/10/05 | 0 | |
alternative version | Greg T. | 05/18/05 | 10 | |
In words | Daniel Straight | 07/10/06 | 1 | |
wall-based OO version | Kevin Baird | 07/07/05 | 2 | |
monkeypatch and anonymous procs | J. B. Rainsberger | 04/04/07 | 0 | |
Readably re-opening Integer, teetotaller | Eric Budd | 01/06/08 | 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
Jannis Harder said on 08/18/06 20:47:11
This is far from minimal. Take a look at http://codegolf.com/competition/index/1
C.G.E. said on 10/12/06 15:25:01
This is unfortunately nowhere near being a minimal version, as Jannis Harder reported. This is somewhat better, trimming off 101 bytes, though still 9% bigger than the smallest Ruby entry. As of posting this, it is in the top 15 results on codegolf for Ruby. Please don't abuse it.
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}.
"}
barrym said on 06/26/10 09:51:34
Before you rip on this version, please note that Anonymous is handling the
"No more" case, which codegolf did not include in their competition specs.
Of course, there still appears to be some room for inprovement.