10 REM BASIC Version of 99 Bottles of beer 20 FOR X=100 TO 1 STEP -1 30 PRINT X;"Bottle(s) of beer on the wall,";X;"bottle(s) of beer" 40 PRINT "Take one down and pass it around," 50 PRINT X-1;"bottle(s) of beer on the wall" 60 NEXT ##```## use Lingua::EN::Inflect 'inflect'; \$n=shift||99; print inflect<## 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 #### 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. 98 bottles of beer on the wall, 98 bottles of beer. Take one down and pass it around, 97 bottles of beer on the wall. 97 bottles of beer on the wall, 97 bottles of beer. Take one down and pass it around, 96 bottles of beer on the wall. ... 3 bottles of beer on the wall, 3 bottles of beer. Take one down and pass it around, 2 bottles of beer on the wall. 2 bottles of beer on the wall, 2 bottles of beer. 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. Go to the store and buy some more, 99 bottles of beer on the wall. #### 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 #### 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 some more, ",b,". "for-99..-1 #### @{sub b{[@b=(abs||No,bottle.'s'x!!++\$_,of,beer),on,the,wall]}b} #### 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 some more" #### 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 and pass it around"or"Go to the store and buy some more",z()) #### 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],""} #### z+w=" on the wall" #### 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. 98 bottles of beer on the wall, 98 bottles of beer. Take one down and pass it around, 97 bottles of beer on the wall. 97 bottles of beer on the wall, 97 bottles of beer. Take one down and pass it around, 96 bottles of beer on the wall. ... 3 bottles of beer on the wall, 3 bottles of beer. Take one down and pass it around, 2 bottles of beer on the wall. 2 bottles of beer on the wall, 2 bottles of beer. 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. Go to the store and buy some more, 99 bottles of beer on the wall. #### 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. 98 bottles of beer on the wall, 98 bottles of beer. ----------------------------------------------------------------- Take one down and pass it around, 97 bottles of beer on the wall. 97 bottles of beer on the wall, 97 bottles of beer. ----------------------------------------------------------------- ... ----------------------------------------------------------------- Take one down and pass it around, 2 bottles of beer on the wall. 2 bottles of beer on the wall, 2 bottles of beer. ----------------------------------------------------------------- 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. ----------------------------------------------------------------- Go to the store and buy some more, 99 bottles of beer on the wall. #### Go to the store and buy some more, 99 bottles of beer on the wall. 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. 98 bottles of beer on the wall, 98 bottles of beer. ----------------------------------------------------------------- Take one down and pass it around, 97 bottles of beer on the wall. 97 bottles of beer on the wall, 97 bottles of beer. ----------------------------------------------------------------- ... ----------------------------------------------------------------- Take one down and pass it around, 2 bottles of beer on the wall. 2 bottles of beer on the wall, 2 bottles of beer. ----------------------------------------------------------------- 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. #### join("Take one down and pass it around",map{@c=(@b=(99-\$_,bottle.'s'x!/98/,of,beer),on,the,wall);", @c. @c, @b. "}0..98)=~/ /;print\$'."Go to the store and buy some more\$`" #### somearray.join("string") #### somearray*"string" #### "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"}. #{c}, #{b}. "}*"Take one down and pass it around"=~/ /;puts\$'+\$` #### "Go to the store and buy some more"+(-99..-1).map{|n|", #{b=-n," bottles"[0,6-n]+" of beer"," on the wall"}. #{b}, %s%s. "%b}*"Take one down and pass it around"=~/ /;puts\$'+\$` #### 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] #### 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] #### 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 more"][1/c+c%2]+",",[y[:-12]+".",y+".\n"][c%2];c-=1 #### 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 more"][j=1/n+1&~n-=1]<<", #{y[0,2+j]}. "+\$/*j} #### bottle."s"x!!++\$_,of,beer # Perl bottl.(\$_?es:e),of,beer # Perl bottle.'s'x1!~\$n,of,beer # Perl bottle.'s'x!/98/,of,beer # Perl "bottle#{'s'if N!=1} of beer" # Ruby " bottle"+"s of beer"[1/-n,9] # Ruby " bottles"[0,6-n]+" of beer" # Ruby "bottle"+"s of beer"[3/n%3,9] # Ruby "bottle"+"s of beer"[1/n:] # Python #### "bottle\$x of beer" #### @c=(@b=(++\$n,bottle.\$&,of,beer),on,the,wall),s/^/Take one down and pass it around, @c. @c, @b. /,/s/for(\$_)x99;/,.* /;print\$'."Go to the store and buy some more\$&" #### s/./\$& \$&/gfor(\$_="- ")x pop;print #### /s/until@c=(@b=(++\$n,bottle.\$&,of,beer),on,the,wall),s/^/Take one down and pass it around, @c. @c, @b. /,/, 99.* /;print\$'."Go to the store and buy some more\$&" #### /s/until@c=(\$b=++\$n." bottle\$& of beer",on,the,wall),s/^/Take one down and pass it around, @c. @c, \$b. /,/, 99.* /;print\$'."Go to the store and buy some more\$&" #### /s/until@c=(++\$n." bottle\$& of beer",on,the,wall),s/^/Take one down and pass it around, @c. @c, \$c[0]. /,/99.* /;print\$'."Go to the store and buy some more, \$&" #### 1.upto(99){|n|~/s/;\$_="Take one down and pass it around, #{c="#{b=n," bottle#\$& of beer"} on the wall"}. #{c}, #{b}. #\$_"} ~/,.* /;puts\$'+"Go to the store and buy some more"+\$& #### n=0 ~/s/ until/, 99.* /=~\$_="Take one down and pass it around, #{c="#{b=n+=1," bottle#\$& of beer"} on the wall"}. #{c}, #{b}. #\$_";puts\$'+"Go to the store and buy some more"+\$& #### b=[99," bottles of beer"," on the wall"] print "%s%s\n"%b #### 99 bottles of beer #### TypeError: not enough arguments for format string #### @b=(99," bottles of beer"," on the wall"); printf "%s%s\n",@b; #### b=[99," bottles of beer"," on the wall"] print "%s%s\n"%tuple(b) #### TypeError: not all arguments converted during string formatting #### b=[99," bottles of beer"," on the wall"] print "%s%s%s\n"%tuple(b) #### 99 bottles of beer on the wall #### 1.upto(99){|n|~/s/;\$_="Take one down and pass it around, #{c=n," bottle#\$& of beer"," on the wall"}. #{c}, %s%s. #\$_"%c} ~/,.* /;puts\$'+"Go to the store and buy some more"+\$& #### 1st 162 rhebus Perl 2nd 162 eyepopslikeamosquito Perl 3rd 165 0xF Perl 4th 166 dgzj001 Perl 5th 167 shinh Perl 6th 170 komondorok Perl 7th 170 ySas Perl 8th 171 flagitious Perl 9th 171 o0lit3 Perl 10th 171 gorash Perl #### 1st 162 rhebus 2nd 162 eyepopslikeamosquito 3rd 165 0xF 4th 166 dgzj001 5th 167 shinh 6th 170 komondorok 7th 170 ySas 8th 171 flagitious 9th 171 o0lit3 10th 171 gorash 11th 173 jgoon 12th 173 volte 13th 174 g.allen 14th 174 terjek 15th 174 bearstearns 16th 174 raymundo 17th 174 ott 18th 174 ozy4dm 19th 174 sixmen 20th 174 Aidy 21st 174 szeryf 22nd 174 Shuman 23rd 174 stressedlemming 24th 175 Ciaran 25th 175 arpad 26th 175 ergasun 27th 175 Nisse 28th 176 jojo 29th 176 Zeithase 30th 177 moq 31st 177 olivier 32nd 178 leus 33rd 179 kounoike 34th 179 yojeb 35th 180 Bryan 36th 181 lima1 37th 181 agenticarus 38th 181 pace_t_zulu 39th 181 zkhr 40th 182 fluffle ... 60th 193 grizzley 65th 195 Jasper 89th 204 chargrill 98th 209 yanick #### 1st 173 flagitious 2nd 176 eyepopslikeamosquito 3rd 177 eban 4th 177 bitsweat 5th 177 leonid 6th 180 tal 7th 180 emiltin 8th 181 yowa 9th 182 oxy4dm 10th 182 shinh 11th 182 noop 12th 182 J-_-L 13th 183 kik 14th 183 yvl 15th 184 tobyaw 16th 185 ksk 17th 186 jojo 18th 186 carldr 19th 186 pace_t_zulu 20th 187 adel #### 1st 182 hallvabo 2nd 183 logan 3rd 183 uli 4th 189 Mark Byers 5th 190 hiro.suzuki 6th 192 primo 7th 193 eyepopslikeamosquito 8th 195 recursive 9th 195 tryeng 10th 195 etaronis 11th 196 kt3k 12th 197 gtalpo 13th 197 ProfessorO 14th 198 lifthrasiir 15th 198 Jay 16th 198 SergeantPepper 17th 199 hirose 18th 199 max 19th 200 Dilb 20th 200 yonilevy #### 1st 172 ToastyX 2nd 173 eyepopslikeamosquito 3rd 175 alab 4th 175 Morgil 5th 178 jln 6th 178 cms 7th 179 hamori 8th 180 hiro.suzuki 9th 183 eyepopper 10th 185 Leafy 11th 186 carldr 12th 191 shinh 13th 193 heavyware 14th 197 Shadlan 15th 198 davidpogson 16th 198 lxlh 17th 199 echofish 18th 200 phoe 19th 201 underdonges 20th 203 Theory ```