/*
* A187211.c
* Calculates the number of Q-toothpicks added in the nth generation in the Q-toothpick cellular automaton
*
* Created by Nathaniel Johnston (nathaniel@nathanieljohnston.com)
* March 26, 2011
*/
#include
#include
unsigned int prevPts = 1, numPts = 1, 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