Ninety-Nine Bottles Of Beer
August 5, 2011
We’ve been working hard for the last few exercises, and it is Friday, so we’ll have a little bit of fun. You all know the song, right?
Your task is to write a program that prints the lyrics to the popular song “Ninety-Nine Bottles Of Beer;” if this program seems too simple for you, make your solution as outlandish as you can — I definitely want to see a solution in Intercal or Brainf*ck. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
already amazingy done in every possibne way : http://99-bottles-of-beer.net/
UNO is based in one simple principle: #=def, $=print, ?=cond, @=loop is all you need to build any algorithm
Wrote this a while ago for Rosetta Code:
ok, sorry :)
First time poster. But I’ll give it a shot.
using System;
class Program
{
static void Main(string[] args)
{
for (int number = 99; number > 0; number–)
{
int nextNumber = number – 1;
Console.WriteLine("{0} {1} of beer on the wall, {0} {1} of beer…", number, number > 1 ? "bottles":"bottle" );
Console.WriteLine("Take one down, pass it around {0} {1} of beer on the wall.", nextNumber, nextNumber != 1 ? "bottles" : "bottle");
Console.WriteLine();
}//end for
}
}
Try that again.
Implementations in a zillion languages, including Brainf*ck and INTERCAL:
http://99-bottles-of-beer.net/
http://99-bottles-of-beer.net/language-brainfuck-101.html
http://99-bottles-of-beer.net/language-intercal-333.html
Some timing… I recently wrote two versions of the “song”
http://www.emmanueloga.com/2011/07/29/drinking-contest.html
Greetings.
I once SSH’d into my roommate’s mac and ran this little bash script while I was at work and he was home alone.
for ((i=99; i>0 ; i–));
do
let “j = i – 1”;
say $i bottles of beer on the wall;
say $i bottles of beer;
say take one down ;
say pass it around;
say $j bottles of beer on the wall;
done
Then I denied all knowledge of it, and told him the computer must have just been really bored.
def song(num):
if num == 0:
print “Song is over”
elif num == 1:
print str(num) + ” bottle of beer on the wall”
else:
print str(num) + ” bottles of beer on the wall”
song(num-1)
Nothing particularly clever, but FWIW… In PLT Racket.