Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Drunk on golf: 99 Bottles of Beer

by eyepopslikeamosquito (Archbishop)
on May 08, 2011 at 12:41 UTC ( [id://903641]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    10 REM BASIC Version of 99 Bottles of beer
    20 FOR X=100 TO 1 STEP -1
    ...
    40 PRINT "Take one down and pass it around,"
    50 PRINT X-1;"bottle(s) of beer on the wall"
    60 NEXT
    
  2. or download this
    use Lingua::EN::Inflect 'inflect';
    $n=shift||99;
    ...
    Take one down, pass it around,
    NO(bottle of beer,@{[--$n]}) on the wall.
    BURP
    
  3. or download this
    sub
    b{[@b=(abs||No,bottle."s"x!!++$_,of,beer),on,the,wall]}print
    "@{+b},\n@b,\nTake one down, pass it around,\n@{+b}.\n"
    for-pop||-99..-1
    
  4. or download this
    99 bottles of beer on the wall, 99 bottles of beer.
    Take one down and pass it around, 98 bottles of beer on the wall.
    ...
    
    1 bottle of beer on the wall, 1 bottle of beer.
    Go to the store and buy some more, 99 bottles of beer on the wall.
    
  5. or download this
    sub b{[@b=(abs||99,bottle."s"x!!++$_,of,beer),on,the,wall]}print"@{+b}
    +, @b.
    ",$_?"Take one down and pass it around":"Go to the store and buy some 
    +more",", @{+b}.
    
    "for-99..-1
    
  6. or download this
    sub b{@b=(-$_++||99,bottl.($_?es:e),of,beer);"@b on the wall"}print+b,
    +", @b.
    ",$_?"Take one down and pass it around, ":"Go to the store and buy som
    +e more, ",b,".
    
    "for-99..-1
    
  7. or download this
    @{sub b{[@b=(abs||No,bottle.'s'x!!++$_,of,beer),on,the,wall]}b}
    
  8. or download this
    print"@{sub b{[@y=($n||=99,bottle.'s'x1!~$n,of,beer),on,the,wall]}b}, 
    +@y.
    $_, @{b--$n}.
    
    "for("Take one down and pass it around")x98,"Go to the store and buy s
    +ome more"
    
  9. or download this
    n=99
    z=lambda:`n or 99`+" bottle"+"s of beer on the wall"[n==1:]
    while n:y=z();n-=1;print"%s, %s.\n"*2%(y,y[:-12],n and"Take one down a
    +nd pass it around"or"Go to the store and buy some more",z())
    
  10. or download this
    def z
    "#{N<1?99:N} bottle#{'s'if N!=1} of beer"end
    (N=99).times{puts"%s, %s.
    "*2%[z+w=" on the wall",z,1>(N-=1)?"Go to the store and buy some more"
    +:"Take one down and pass it around",z+w],""}
    
  11. or download this
    z+w=" on the wall"
    
  12. or download this
    99 bottles of beer on the wall, 99 bottles of beer.
    Take one down and pass it around, 98 bottles of beer on the wall.
    ...
    
    1 bottle of beer on the wall, 1 bottle of beer.
    Go to the store and buy some more, 99 bottles of beer on the wall.
    
  13. or download this
    99 bottles of beer on the wall, 99 bottles of beer.
    -----------------------------------------------------------------
    ...
    1 bottle of beer on the wall, 1 bottle of beer.
    -----------------------------------------------------------------
    Go to the store and buy some more, 99 bottles of beer on the wall.
    
  14. or download this
    Go to the store and buy some more, 99 bottles of beer on the wall.
    
    ...
    Take one down and pass it around, 1 bottle of beer on the wall.
    
    1 bottle of beer on the wall, 1 bottle of beer.
    
  15. or download this
    join("Take one down and pass it around",map{@c=(@b=(99-$_,bottle.'s'x!
    +/98/,of,beer),on,the,wall);", @c.
    
    ...
    "}0..98)=~/
    
    /;print$'."Go to the store and buy some more$`"
    
  16. or download this
    somearray.join("string")
    
  17. or download this
    somearray*"string"
    
  18. or download this
    "Go to the store and buy some more"+(-99..-1).map{|n|", #{c="#{b=-n," 
    +bottle"+"s of beer"[1/-n,9]} on the wall"}.
    
    ...
    "}*"Take one down and pass it around"=~/
    
    /;puts$'+$`
    
  19. or download this
    "Go to the store and buy some more"+(-99..-1).map{|n|", #{b=-n," bottl
    +es"[0,6-n]+" of beer"," on the wall"}.
    
    ...
    "%b}*"Take one down and pass it around"=~/
    
    /;puts$'+$`
    
  20. or download this
    r="Take one down and pass it around".join(", %s.\n\n"%c+c+", %s.\n"%c[
    +:-12]for c in[`99-z`+" bottle"+"s of beer on the wall"[z/98:]for z in
    + range(99)])
    print r[35:]+"Go to the store and buy some more"+r[:34]
    
  21. or download this
    n=99
    y="Go to the store and buy some more"
    while n:c=`n`+" bottle"+"s of beer on the wall"[1/n:];y+=", %s.\n\n"%c
    ++c+", %s.\nTake one down and pass it around"%c[:-12];n-=1
    print y[68:-32]+y[:66]
    
  22. or download this
    c=198
    while c:y=`c/2or 99`+" bottle"+"s of beer on the wall"[3/c%3:];print[y
    +,"Take one down and pass it around","Go to the store and buy some mor
    +e"][1/c+c%2]+",",[y[:-12]+".",y+".\n"][c%2];c-=1
    
  23. or download this
    n=198
    loop{$><<[y=[n/2%-99+99," bottle"+"s of beer"[3/n%3,9]," on the wall"]
    +,"Take one down and pass it around","Go to the store and buy some mor
    +e"][j=1/n+1&~n-=1]<<", #{y[0,2+j]}.
    "+$/*j}
    
  24. or download this
    bottle."s"x!!++$_,of,beer        # Perl
    bottl.($_?es:e),of,beer          # Perl
    ...
    " bottles"[0,6-n]+" of beer"     # Ruby
    "bottle"+"s of beer"[3/n%3,9]    # Ruby
    "bottle"+"s of beer"[1/n:]       # Python
    
  25. or download this
    "bottle$x of beer"
    
  26. or download this
    @c=(@b=(++$n,bottle.$&,of,beer),on,the,wall),s/^/Take one down and pas
    +s it around, @c.
    
    ...
    /,/s/for($_)x99;/,.*
    
    /;print$'."Go to the store and buy some more$&"
    
  27. or download this
    s/./$& $&/gfor($_="-
    ")x pop;print
    
  28. or download this
    /s/until@c=(@b=(++$n,bottle.$&,of,beer),on,the,wall),s/^/Take one down
    + and pass it around, @c.
    
    ...
    /,/, 99.*
    
    /;print$'."Go to the store and buy some more$&"
    
  29. or download this
    /s/until@c=($b=++$n." bottle$& of beer",on,the,wall),s/^/Take one down
    + and pass it around, @c.
    
    ...
    /,/, 99.*
    
    /;print$'."Go to the store and buy some more$&"
    
  30. or download this
    /s/until@c=(++$n." bottle$& of beer",on,the,wall),s/^/Take one down an
    +d pass it around, @c.
    
    ...
    /,/99.*
    
    /;print$'."Go to the store and buy some more, $&"
    
  31. or download this
    1.upto(99){|n|~/s/;$_="Take one down and pass it around, #{c="#{b=n," 
    +bottle#$& of beer"} on the wall"}.
    
    ...
    ~/,.*
    
    /;puts$'+"Go to the store and buy some more"+$&
    
  32. or download this
    n=0
    ~/s/ until/, 99.*
    ...
    
    #{c}, #{b}.
    #$_";puts$'+"Go to the store and buy some more"+$&
    
  33. or download this
    b=[99," bottles of beer"," on the wall"]
    print "%s%s\n"%b
    
  34. or download this
    99 bottles of beer
    
  35. or download this
    TypeError: not enough arguments for format string
    
  36. or download this
    @b=(99," bottles of beer"," on the wall");
    printf "%s%s\n",@b;
    
  37. or download this
    b=[99," bottles of beer"," on the wall"]
    print "%s%s\n"%tuple(b)
    
  38. or download this
    TypeError: not all arguments converted during string formatting
    
  39. or download this
    b=[99," bottles of beer"," on the wall"]
    print "%s%s%s\n"%tuple(b)
    
  40. or download this
    99 bottles of beer on the wall
    
  41. or download this
    1.upto(99){|n|~/s/;$_="Take one down and pass it around, #{c=n," bottl
    +e#$& of beer"," on the wall"}.
    
    ...
    ~/,.*
    
    /;puts$'+"Go to the store and buy some more"+$&
    
  42. or download this
      1st  162  rhebus                             Perl
      2nd  162  eyepopslikeamosquito               Perl
    ...
      8th  171  flagitious                         Perl
      9th  171  o0lit3                             Perl
     10th  171  gorash                             Perl
    
  43. or download this
      1st  162  rhebus
      2nd  162  eyepopslikeamosquito
    ...
     65th  195  Jasper
     89th  204  chargrill
     98th  209  yanick
    
  44. or download this
      1st  173  flagitious
      2nd  176  eyepopslikeamosquito
    ...
     18th  186  carldr
     19th  186  pace_t_zulu
     20th  187  adel
    
  45. or download this
      1st  182  hallvabo
      2nd  183  logan
    ...
     18th  199  max
     19th  200  Dilb
     20th  200  yonilevy
    
  46. or download this
      1st 172  ToastyX
      2nd 173  eyepopslikeamosquito
    ...
     18th 200  phoe
     19th 201  underdonges
     20th 203  Theory
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://903641]
Approved by ww
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 23:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found