Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: 99 bottles, 2 lines

by lanval (Novice)
on Apr 27, 2004 at 01:57 UTC ( #348388=note: print w/ replies, xml ) Need Help??


in reply to 99 bottles, 2 lines

The problem occurs when you must decide whether to write "bottle" or "bottles". Some replies above do not take this into account despite the original poster doing so. Just for fun, here is my solution (longer than the original though). It is 178 characters long:

($a,$b,$c,$n)=(" bottle"," of beer"," on the wall",99);sub u{$s=$n-1?" +s":();$e="$n$a$s$b"}while($n){u;print"$e$c, $e!\nTake one down, pass +it around,\n";$n--;u;print"$e$c!\n\n"}


Comment on Re: 99 bottles, 2 lines
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://348388]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (12)
As of 2014-12-17 21:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (33 votes), past polls