Thatsa lotta beer!

The statute of limitations is up on this by now, I think…

Back in the day, several ne’er-do-well CS students were enrolled in a certain CS150/151 class/lab, taught by a certain D. Ray with a certain M. Ghose as a lab TA. As the legend goes, they were bored in lab one day (having finished the ridiculously easy assignment in a few minutes, but not being allowed to leave early). They got the idea to put into practice their newfound knowledge of unsigned long integers (32 bits of nonnegative goodness, on those machines) by writing a technological take on the age-old “bottles of beer” song known and loathed by school-bus-drivers everywhere.

The technological take was to make the computers “sing” the verses of “Four billion bottles of beer on the wall” by writing the verses out to a disk. The code looked something* like the following:

#include <stdio.h>
int main(){
   unsigned long long beernum;
   for(beernum=4000000000;beernum>0;beernum–){
      printf(“%llu bottle”,beernum);
      if(beernum!=1) printf(“s”);
      printf(” of beer on the wall,\n”);
      printf(“%llu bottle”,beernum);
      if(beernum!=1) printf(“s”);
      printf(” of beer,\n”);
      printf(“Take one down,\n”);
      printf(“Pass it around,\n”);
      printf(“%llu bottle”,beernum-1);
      if(beernum!=2) printf(“s”);
      printf(” of beer on the wall…\n\n”);
      }
   return(0); //Outta beer, outta here!
   }

They finished writing it, so the story goes, just before the lab period ended, and set it in motion, telling their friend in the next section that it might be a good idea to save his work. Apparently the sysadmins hadn’t heard of disk quotas, because the drives rapidly filled up with the verses of what had to be the world’s longest song. According to aforementioned friend, one of the sysadmins ran into the lab about halfway through the next section, asking for certain students by name.

The interesting thing is, Moore’s Law being what it is, while such files might not fit in a user’s disk quota, they probably wouldn’t crash the server, either; at about 124 bytes per verse, the “song” would take up about 496GB (depending on whose definition of a GB you use.) This would actually fit on the free space on my 1-TB drive on my workstation at home (MSRP of just under a hundred bucks.)

Moore’s Law rocks.

* OK, so this isn’t the original code by a long ways — but it gives the flavor. The original:

  • was written in Pascal, not C;
  • wrote to the disk instead of standard I/O, and
  • probably didn’t have the fancy “bottle” / “bottles” code
This entry was posted in Coding, Humor, Nostalgia. Bookmark the permalink.

One Response to Thatsa lotta beer!

Leave a Reply