Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

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

VersionAuthorDateCommentsRate
Using continuations, singleton classesVictor Borja09/15/069
object-oriented versionMike Gertz04/20/052
shows inheritance, iterators, yield, etcKian Wright06/10/050
alternative versionGreg T.05/18/0510
In wordsDaniel Straight07/10/061
wall-based OO versionKevin Baird07/07/052
monkeypatch and anonymous procsJ. B. Rainsberger04/04/070
Readably re-opening Integer, teetotallerEric Budd01/06/080

Comments

>>  Jannis Harder said on 08/18/06 20:47:11

Jannis Harder 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

C.G.E. 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

barrym 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.

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!

Name:

eMail:

URL:

Security Code:
  
Comment: