develooper Front page | perl.fwp | Postings from May 2003

Re: 99 bottles of beer on the wall

From:
=?iso-8859-1?q?Andrew=20Savige?=
Date:
May 24, 2003 21:57
Subject:
Re: 99 bottles of beer on the wall
Message ID:
20030525045748.70421.qmail@web10908.mail.yahoo.com
Uri Guttman wrote:
> we had this golf game in comp.lang.perl.misc a few years ago over the
> chistmas holiday. google has the whole thread and check out damian's
> entry. :)
>
> 	http://xrl.us/iex

I don't know who was declared the winner five years ago, but
if this is to be a fair golf game, the output must match.
Adjusting Uri's program by changing:
  Take one down and pass it around,
to:
  Take one down, pass it around,
makes Uri's and Ronald's programs produce identical output.
Replacing \n with a hard newline, I score that as:

uri: 168 strokes
-------------------------------------------------------------------
$n=shift||99;@s='s';$o=' on the wall';
print<<B while$n
@{[$b="$n bottle$s[$n==1] of beer"]}$o, $b!
Take one down, pass it around,
${\--$n} bottle$s[$n==1] of beer$o!

B
-------------------------------------------------------------------

ronald: 165 strokes
-------------------------------------------------------------------
$_=shift||99;$b='"$_ bottle$s[$_==1] of beer"';$w=' on the wall';
@s='s';print eval$b,"$w, ",eval$b,"!
Take one down, pass it around,
",eval'$_--;'.$b,$w,
"!

"while$_
-------------------------------------------------------------------

As you might expect, I cannot resist re-opening this golf game,
after a half-time break of four and a half years:

/-\: 150 strokes
-------------------------------------------------------------------
$n=shift||99;$o=' on the wall';
s''"$n bottle"."s"x($n!=1)." of beer"';
print$b=eval,"$o, $b!
Take one down, pass it around,
",!$n--,eval,"$o!

"while$n
-------------------------------------------------------------------

I wonder if this will provoke an alien. ;-)

/-\


http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About