Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Drunk on golf: 99 Bottles of Beer

by eyepopslikeamosquito (Archbishop)
on Jun 12, 2011 at 07:25 UTC ( [id://909285]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    x = "012345"
    s = x[0:3]       # s contains "012"
    ...
    s = x[::-2]      # same thing (using default)
    s = x[::-1]      # s contains "543210" (i.e. string reverse)
    s = x[::0]       # "ValueError: slice step cannot be zero"
    
  2. 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())
    
  3. or download this
    n and"Take one down and pass it around"or"Go to the store and buy some
    + more"
    
  4. or download this
    "Take"if n else"Go to"
    (n>0)*"Take"or"Go to"
    ...
    ("Go to","Take")[n>0]
    n and"Take"or"Go to"
    "GToa kteo"[n>0::2]          # "Slice and Dice" wins this golf!
    
  5. or download this
    99 bottles of beer on the wall,<space>
    99 bottles of beer.\nTake one down and pass it around,<space>
    98 bottles of beer on the wall.\n\n
    
  6. or download this
    i=298
    while~-i:print i/3or 99,'bottle'+'s of beer on the wall.\n\n'[2<i<6:9+
    +i%3*12]+'..\n\nGToa kteo  otnhee  dsotwonr ea nadn dp absusy  isto ma
    +er omuonrde,,'[(i>3)+i%3*68::2],;i-=1
    
  7. or download this
    '..\n\nGToa kteo  otnhee  dsotwonr ea nadn dp absusy  isto maer omuonr
    +de,,'[(i>3)+i%3*68::2]
    
  8. or download this
    i=298
    while~-i:print i/3or 99,'bottle'+'s of beer on the wall'[2<i<6:9+i%3*1
    +4]+('.\n'+'GToa kteo  otnhee  dsotwonr ea nadn dp absusy  isto maer o
    +muonrde,,'[i>3::2],',','.\n\n')[i%3],;i-=1
    
  9. or download this
    i=298
    while~-i:print i/3or 99,'bottle'+'s of beer on the wall.\n\n'[2<i<6:9+
    +i%3*12]+'.X\n.G\noT atkoe  tohnee  sdtoowrne  aanndd  pbausys  siotm 
    +ea rmoourned,,'[3%i+i%3*68::2],;i-=1
    
  10. or download this
    i=297
    while i:print-~i/3or 99,'bottle'+'s of beer on the wall.\n\n'[1<i<5:i%
    +3*14^21]+'..\n\nGToa kteo  otnhee  dsotwonr ea nadn dp absusy  isto m
    +aer omuonrde,,'[i%3-2^-72|2%i::2],;i-=1
    
  11. or download this
    print~$_/3|0||99," bottle",substr("s of beer on the wall.
    
    X",6/$_%2,-4**($_%3)),(", ",$_<-4?".
    Take one down and pass it around, ":".
    Go to the store and buy some more, ")[$_%3-3]for-299..-3
    
  12. or download this
    print-$_/3|0||99," bottle",("s"," of beer"," on the wall",".
    
    ")[5/$_%2..-$_%3+1],($_<-3?".
    Take one down and pass it around, ":".
    Go to the store and buy some more, ",", ")[-$_%3]for-298..-2
    
  13. or download this
    298.downto(2){|i|$><<i/3%-99+99<<" bottle"+"s of beer on the wall.
    
    "[5/i%i..8+i%3*12]<<[i>3?".
    Take one down and pass it around, ":".
    Go to the store and buy some more, ",", "][i%3]}
    
  14. or download this
    298.downto(2){|i|$><<i/3%-99+99<<" bottle"+"s of beer on the wall.
    
    "[5/i%i..8+i%3*12]<<".
    Go to the store and buy some more, .
    Take one down and pass it around, "[3%i*25/2+i%3*34,37]}
    
  15. or download this
    eval"$><<%{#{a=b='#{n} bottl#{"es"[0,n]} of beer',' on the wall'}, #{b
    +}.
    \#{0<(n-=1)?'Take one down and pass it around':(n=99;'Go to the store 
    +and buy some more')}, #{a}.
    
    };"*n=99
    
  16. or download this
    eval %{puts"#{a='#{n} bottle#{n>1?:s:p} of beer on the wall'}, #{a[0,3
    +0]}.
    \#{(n-=1)<1?(n=99;'Go to the store and buy some more'):'Take one down 
    +and pass it around'}, #{a}.
    
    "
    }*n=99
    
  17. or download this
    $_="Take one down and pass it around, #{~/s/;c=4-$.-=1," bottle#$& of 
    +beer"," on the wall"}.
    
    #{c}, %s%s.
    #$_"%c until/, 99\D+/;puts$'+"Go to the store and buy some more"+$&
    
  18. 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$'+$`
    
  19. or download this
    # Based on emiltin.
    eval"$><<%{#{a=b='#{n} bottl#{"es"[0,n]} of beer',' on the wall'}, #{b
    +}.
    \#{0<(n-=1)?'Take one down and pass it around':'Go to the store and bu
    +y some more'%n=99}, #{a}.
    
    };"*n=99
    
  20. or download this
    # Based on J-_-L.
    eval"$><<%{#{a=b='#{n} bottle#{n>1?:s:p} of beer',' on the wall'}, #{b
    +}.
    ...
    
    }
    "*n=99
    
  21. or download this
    /s/until@c=(@b=(++$n,bottle.$&,of,beer),on,the,wall),s/^/Take one down
    + and pass it around, @c.
    
    @c, @b.
    /,/, 99\D+/;print$'."Go to the store and buy some more$&"
    
  22. or download this
    $_="Take one down and pass it around, #{~/s/;c=4-$.-=1," bottle#$& of 
    +beer"," on the wall"}.
    
    #{c}, %s%s.
    #$_"%c until/, 99\D+/;puts$'+"Go to the store and buy some more"+$&
    
  23. or download this
    i=298
    while~-i:print i/3or 99,'bottle'+'s of beer on the wall.\n\n'[5/i%i:i%
    +3*28^9]+'.X\n.G\noT atkoe  tohnee  sdtoowrne  aanndd  pbausys  siotm 
    +ea rmoourned,,'[i%3*69^3%i::2],;i-=1
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2024-03-28 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found