[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 99 bottles




On Tue, 8 Oct 2002, Daniel Weinreb wrote:

> Hah, that's not minimal.  That's a whopping 157 characters without line
> breaks!  That's positively effusive.
>
> Here's a _real_ minimal version, 139 characters of lovely Perl:
>
> $b=sub{(99_-@_-$_||No)." bottles of beer on the wall\n"};
> warn map{&$b.substr(&$b,0,18)."\nTake one down, pass it
> around\n".&$b(0).$/}0..98
>
> They both handle "no bottles", but they also both blow it with "one
> bottles".  Oh well.

Minimal?  Bah.  Here's my version in Ruby, 131 characters with line
breaks.

@c=(@b='#{n>0?n: :No} bottles of beer')+' on the wall'
eval %{puts"#@c, #@b.
Take one down, pass it around,",(n-=1;"#@c.

");}*n=99

It'll take another 12 characters to do "1 bottle" properly.

Cheers,
Avi