/* * A187216.c * Calculates the number of Q-toothpicks in the nth generation of the Q-toothpick cellular automaton, starting from two opposite Q-toothpicks * * Created by Nathaniel Johnston (nathaniel@nathanieljohnston.com) * April 15, 2011 */ #include #include unsigned int prevPts = 2, numPts = 2, pt[268435455]; FILE *file; unsigned int getCoord (unsigned int pt, unsigned short coord) { unsigned short shift = 14*(coord-1); return (pt & (16383*(1 << shift))) >> shift; } unsigned int getOrien (unsigned int pt) { return (pt & (3 << 28)) >> 28; } unsigned int getPt (unsigned short x, unsigned short y, unsigned short orien) { return x | (y << 14) | (orien << 28); } unsigned char addOrien (unsigned short x, unsigned short y, unsigned short orien) { unsigned int j, nh = 0, nv = 0; unsigned short px, py, po; for(j=0;j