99.downto(0){|i|j=(i==0)?"99":(i-1).to_s;i=i.to_s;s=(i==1)?"":"s";z=(j==1)?"":"s";puts i+" bottle"+s+" of beer on the wall, "+i+" bottle"+s+" of beer.\n"+(i=="0"?"Go to the store and buy some more":"Take one down and pass it around")+", "+j+" bottle"+z+" of beer on the wall.\n\n"}
robmiller said:I suck far far too much at Ruby
(281 with loads of potential for reduction)
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottles of beer on the wall.
1 bottles of beer on the wall, 1 bottles of beer.
Take one down and pass it around, 0 bottles of beer on the wall.
0 bottles of beer on the wall, 0 bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
def b(i)"#{i} bottle#{i>1?'s':''} of beer"end;def l(i)w=" on the wall"; ["#{b(i)}#{w}, #{b(i)}.",i>1?"Take one down and pass it around, #{b(i-1)}#{w}.":"Go to the store and buy some more, #{b(99)}#{w}.", ""]end;99.downto(1) { |x| puts l(x) }
robmiller said:Can't you get it even smaller by using braces instead of end? Also doesn't it use the singular for 0 bottles too?
Nicely done though, I love Ruby for stuff like this
def b(i)"#{i} bottle#{i>1?'s':''} of beer"end;99.downto(1){|i|w=" on the wall";puts ["#{b(i)}#{w}, #{b(i)}.",i>1?"Take one down and pass it around, #{b(i-1)}#{w}.":"Go to the store and buy some more, #{b(99)}#{w}.", ""]}
Set oF = CreateObject("Scripting.FileSystemObject")
Set oT = oF.CreateTextFile("c:\b.txt", 2)
c = 99
b = 98
While c > 0
oT.WriteLine C & " bottles of beer on the wall, " & c & " bottles of beer." & vbcrlf & "Take one down and pass it around, " & b & "bottles of beer on the wall." & vbcrlf
c = c - 1
b = b - 1
Wend
set of = createobject("scripting.filesystemobject")
Set ot = of.createtextfile("c:\b.txt", 2)
c = 99
b = 98
a = "bottles of beer"
d = a & " on the wall"
while c > 1
ot.writeline C & " " & d & ", " & c & " " & a &"." & vbcrlf & "Take one down and pass it around, " & b & " " & d & "." & vbcrlf
c = c - 1
b = b - 1
wend
ot.writeline "Go to the store and buy some more, 99 " & d & "."
using System;class a{static void Main(){string j=" bottle";string b=" of beer";string k=" on the wall";for(int i=99;i>1;i--){string s=i>1?"s":"";Console.WriteLine(i+j+s+b+k+", "+i+j+s+b+".\nTake one down and pass it around, "+(i-1)+j+(s=i==2?"":"s")+b+k+".");}Console.WriteLine("1 bottle"+b+k+", 1 bottle"+b+",\nGo to the store and buy some more, 99 bottles"+b+k+".");}}
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.
1 B$="bottles of beer ":C$="on the wall":D$="Take one down and pass it around, "
:E$="1 bottle of beer"
2 FOR A=99 TO 3 STEP -1:PRINT A;B$;C$",";A;B$;".":PRINT D$;A-1;B$;C$;".":NEXT A
3 PRINT "2 ";B$;C$;", 2 ";B$;"."
5 PRINT "Go to the store and buy some more, 99 ";B$;C$;"."
A cursor glance, but does it handle theRaist said:stuff..
#!/bin/sh
a=' bottles of beer'
b="$a on the wall"
for i in `seq 99 -1 1`;do echo -e "$i$b, $i$a.\nTake one down and pass it around, $[$i-1]$b.\n"|sed "/ 1 /s/es/e/g;/ 0/s/^.*$/Go to the store and buy some more, 99$b./";done
Doh! 295 bytes.riddlermarc said:A cursor glance, but does it handle the
"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."
part?
Results said:Take one down and pass it around, 7 bottles of beer on the wall.
7 bottles of beer on the wall, 7 bottles of beer .
Take one down and pass it around, 6 bottles of beer on the wall.
6 bottles of beer on the wall, 6 bottles of beer .
Take one down and pass it around, 5 bottles of beer on the wall.
5 bottles of beer on the wall, 5 bottles of beer .
Take one down and pass it around, 4 bottles of beer on the wall.
4 bottles of beer on the wall, 4 bottles of beer .
Take one down and pass it around, 3 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.
1 B$="bottles of beer ":C$="on the wall":D$="Take one down and pass it around, "
:E$="1 bottle of beer "
2 FOR A=99 TO 3 STEP -1:PRINT A;B$;C$",";A;B$;".":PRINT D$;A-1;B$;C$;".":NEXT A
3 PRINT "2 ";B$;C$;", 2 ";B$;".":PRINT D$;E$;C$:PRINT E$;C$;", ";E$;"."
5 PRINT "Go to the store and buy some more, 99 ";B$;C$;"."
Nice!JonB said:PHP:<? for($c=" bottle",$q=" of beer",$w=" on the wall",$x=99;$a=$x.$c.($x>1?s:"").$q,$x;)echo"$a$w, $a.",$x>1?"\nTake one down and pass it around, ":"\nGo to the store and buy some more, ",!--$x?99:$x,$c,$x!=1?s:"","$q$w.\n\n";
224