The story behind rspec kung fu hamster

rspec-kungfuhamster originated as a joke on a POS development team I worked on almost 10 years ago. In the battle of scope creep and requirements changes, we all got a bit loopy and a couple members of the team drew up an ASCII animated "kung fu hamster" as a terminal-based spinner while the credit card authorization (often by modem) was taking place.

Strangely, product ownership didn't see the humor in so much time being spent on the animation.

I decided to revive kung fu hamster as an rspec formatter in honor of those days of solving technical problems on out-of-date SCO Unix boxes without access to anything but standard and home grown libraries, as well as the two team members that have passed away at far too young an age since.

 

This kid knew enough to be dangerous.

Running this old code, which was probably not actually turned in for anything, through the gcc compiler alone showed that there was a glaring error that would have been exposed on the the first run.

Beyond the initial compiler warnings, there are the ALL CAPS variables, the while loops used as pure for loops...

 
#include "stdio.h"
main()
{
 
    int rows,columns,ROW, COLUMN;
    scanf("%d %d",ROW,COLUMN);
    rows = 0;
    columns = 0;
    while(columns++ < COLUMN)
        printf("xdb");
    printf("n");
    rows += 1;
    while(rows++ < (ROW - 2)){
        columns = 0;
        printf("xdb");
        while(columns++ < (COLUMN - 2)){
            printf(" ");
            }
        printf("xdbn");
        }
    columns = 0;
    while(columns++ < COLUMN) {
        printf("xdb");
        }
 
 
}

I miss C programming. Program to find prime numbers

Uses unsigned long long, goes up to ULONG_LONG_MAX.

Intel Core Duo 2 processor, running Cygwin on Windows XP, and compiled using gcc 3.4.4. Stops at first million results due to time. Can reasonably get to 10 million, if you're willing to wait.


#include <stdio.h>
#include <math.h>
#include <limits.h>

int main(int argc, char **argv)
{
unsigned long long divisor, max_divisor, prime_test;
int break_time = 0;

printf("%llun", 2LL);
for(prime_test = 3LL; prime_test < ULONG_LONG_MAX; prime_test+=2LL)
{
max_divisor=1LL+sqrt(prime_test);
for(divisor=3LL;divisor <= max_divisor; divisor+=2LL)
{
if(prime_test % divisor == 0)
{
break;
}
}
if(divisor >= max_divisor)
{
printf("%llun", prime_test);
}
else
{
continue;
}
break_time++;
if(break_time == 999999)
{
break;
}
}
return 0;
}