/* crypt.tc - 1/7/9 - lrb /* send+more=money - what are the digits for each letter? /* works under Linux (32-bit integer support needed) /* made all var's global - other improvements int s,e,n,d,m,o,r,y int x,w,z exp [ /* returns 1 if 8-tuple solves addition problem else returns 0 x=1000*s+100*e+10*n+d w=1000*m+100*o+10*r+e z=10000*m+1000*o+100*n+10*e+y return (x+w)==z ] next1 [ ++e while (e==m) ++e ] next2 [ ++n while ((n==m)+(n==e)) ++n ] next3 [ ++d while ((d==m)+(d==e)+(d==n)) ++d ] next4 [ ++s while ((s==m)+(s==e)+(s==n)+(s==d)) ++s ] next5 [ ++o while ((o==m)+(o==e)+(o==n)+(o==d)+(o==s)) ++o ] next6 [ ++r while ((r==m)+(r==e)+(r==n)+(r==d)+(r==s)+(r==o)) ++r ] next7 [ ++y while ((y==m)+(y==e)+(y==n)+(y==d)+(y==s)+(y==o)+(y==r)) ++y ] all [ /* returns 1 if y is not equal to all others else returns 0 return !((y==m)+(y==e)+(y==n)+(y==d)+(y==s)+(y==o)+(y==r)) ] crypt [ /* determine and display solution to send+more=money cryptarithm hilo '1';colorf '4';pl "crypt.tc - 1/7/9 - lrb";colorf '7';pl "";pl "" m=1 for (e=0;e<10;next1) [ for (n=0;n<10;next2) [ for (d=0;d<10;next3) [ for (s=1;s<10;next4) [ for (o=0;o<10;next5) [ for (r=0;r<10;next6) [ for (y=0;y<10;next7) [ if (all) if (exp) [ ps "s =";pn s;ps " e =";pn e;ps " n =";pn n;ps " d =";pn d pl "m =";pn m;ps " o =";pn o;ps " r =";pn r;ps " e =";pn e pl "y =";pn y pl "";pl "";pn x;ps " +";pn w;ps " =";pn z pl "";pl "" exit ] ]]]]]]] ]