The Joys of Programming

One of the things I enjoy is programming computers. This section has a few examples of things I have found to be of interest, plus a few little programs what I have wrote. See the menu on the right for details.

Most recently I have added a utility for sudoku - designed to take some of the drudgery out of solving sudoku problems.

Students of computing might be interested in the Intercal programming language. It is a mature language, being written in 1972. It is Turing Complete, has compilers for several different systems and is completely ludicrous. Almost impossible to program in, it represents an absolute nadir in the history of man-machine interface.

I am given to understand that it started as a spoof on COBOL and FORTRAN but has subsequently got out of hand. Thoroughly recommended.

Interesting Stuff

Some things are just interesting. For instance, I learned the other day that you can swap two values using the exclusive OR operator. After a little effort I worked out that it went like this:

a = (a ^ b) ^ (b ^=  (a ^ b));
	

This little snippet sets a equal to b and b equal to a.

This next one calculates pi to about 800 decimal places. I can't remember where I found it and I still don't have any clear idea of how it works.

int a=10000,b,c=2800,d,e,f[2801],g;
main()
{
    for(;b-c;)
        f[b++]=a/5;
    for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)
        for(b=c;d+=f[b]*a, f[b]=d%--g,d/=g--,--b;d*=b)
           	;

    printf("\n");
}
	

Let me know of any other interesting programming stuff you might find.

date

last updated
time