/* npr.tc - tct - 1/7,8/2010 int noth,in,g; /* variable names inspired by ceb /* "I spent about 45 minutes on it and came up with noth * in / g." char op1,op2; int year; int lctr; disp [ /* display a solution pl "";MC(noth,14);putchar op1;MC(in,14);putchar op2;MC(g,14); putchar('=');MC(year,14); if (++lctr>19) [lctr=0;sak;] ] npr [ /* main function pl "npr.tc - tct - 1/8/2010";pl ""; pl "see http://primepuzzle.com/tc/npr.html";pl ""; int w,maxin; for (year=1;year<=5000;++year) [ for (noth=2;noth<=2345;noth=noth*10+noth%10+1) [ maxin=w=noth%10+1; /* if noth = 23, maxin starts off at 4 while (w<6) [++w;maxin=maxin*10+w;] /* determines maximum value of in for (in=noth%10+1;in<=maxin;in=in*10+in%10+1) [ g=w=in%10+1;while (w<7) [++w;g=g*10+w;] /* determines g if (noth+in+g==year) [op1='+';op2='+';disp] if (noth+in-g==year) [op1='+';op2='-';disp] if (noth+in*g==year) [op1='+';op2='*';disp] if ((in%g==0)*(noth+in/g==year)) [op1='+';op2='/';disp] if (noth-in+g==year) [op1='-';op2='+';disp] if (noth-in-g==year) [op1='-';op2='-';disp] if (noth-in*g==year) [op1='-';op2='*';disp] if ((in%g==0)*(noth-in/g==year)) [op1='-';op2='/';disp] if (noth*in+g==year) [op1='*';op2='+';disp] if (noth*in-g==year) [op1='*';op2='-';disp] if (noth*in*g==year) [op1='*';op2='*';disp] if ((noth*in%g==0)*(noth*in/g==year)) [op1='*';op2='/';disp] if ((noth%in==0)*(noth/in+g==year)) [op1='/';op2='+';disp] if ((noth%in==0)*noth/in-g==year) [op1='/';op2='-';disp] if ((noth%in==0)*noth/in*g==year) [op1='/';op2='*';disp] if ((noth%in==0)*(noth/in%g==0)*(noth/in/g==year)) [op1='/';op2='/';disp] ] ] ] pl "" ]