Cryptarithm: PRINT + MORE = MONEY. Task: Minimal & Maximal solutions; How Many?
I have a nagging suspicion that a carefully-reasoned approach is expected here, laying out in a few lines how the solutions have to be such-and-such. For me, solving cryptarithms (in my youth) was always a messy affair: lots of scribbling laying out the possibilities - but basically brute force. Nowadays, I'm reasonably comfortable with Mathematica (albeit in an amateurish fashion) to be able to assign the search thereto with an off-the-cuff program that runs through the possibilities and simply weeds out the failures. To be fair, it took a second re-write to get the bracketing of the six DO loops and eight IF statements correct. The exercise reminded me of a once-upon-a-time desire to write a generalized all-purpose program to solve simple cryptarithms like this. SPOILER SPACE STARTS d0=Ran ge[0,9 ];c=0; Do[Do[ If[e!= t,s1=t +e;d1= Intege rPart[ s1/10] ;y=s1- (10*d1 );If[y !=e&&y !=t,Do [Do[If [n!=e& &n!=t& &n!=y, r=10*d 2+e-n- d1;If[ Member Q[d0,r ]&&r!= n&&r!= y&&r!= e&&r!= t,Do[D o[If[o !=r&&o !=n&&o !=y&&o !=e&&o !=t,i= 10*d3+ n-o-d2 ;If[Me mberQ[ d0,i]& &i!=o& &i!=r& &i!=n& &i!=y& &i!=e& &i!=t, m=10+o -r-d3; If[Mem berQ[R ange[2 ,9],m] &&m!=i &&m!=o &&m!=r &&m!=n &&m!=y &&m!=e &&m!=t ,p=m-1 ;If[p! =m&&p! =i&&p! =o&&p! =r&&p! =n&&p! =y&&p! =e&&p! =t,c++ ;Print [p,r,i ,n,t]; Print[ "+",m, o,r,e] ;Print [m,o,n ,e,y," =#",c] ;Print []]]]] ,{o,0, 9}],{d 3,0,1} ]]],{n ,0,9}] ,{d2,0 ,1}]]] ,{e,1, 9}],{t ,1,9}] SPOILER SPACE ENDS In order of increasing MONEY, I have 18 solutions: PRINT MORE MONEY # 0 18456 2083 20539 # 1 18563 2084 20647 # 2 18674 2085 20759 # 3 27906 3178 31084 # 4 28574 3186 31760 # 5 36892 4065 40957 # 6 36905 4167 41072 # 7 36908 4167 41075 # 8 54781 6042 60823 # 9 54789 6043 60832 #10 57048 6371 63419 #11 57049 6372 63421 #12 57839 6471 64310 #13 63908 7134 71042 #14 64913 7245 72158 #15 74369 8241 82610 #16 76052 8461 84513 #17 76059 8462 84521 #18 FIN