# A computer science problem by Rocco Dalto

Computer Science Level pending

Let $$*$$ represent the operation of multiplication of integers.

$\begin{array} { cccccc } & & & D & O & G \\ * & & & T & W & O \\ \hline & W & H & A & K & O \\ \end{array}$

In the product shown above each letter represents a digit. Let $$a_{1}$$ be the maximum value for $$\overline{WHACKO}$$, $$b_{1}$$ be the minimum value for $$\overline{WHACKO}$$ and $$n_{1}$$ be all possible products of $$\: \overline{DOG} * \overline{TWO} = \overline{WHACKO}$$ and $$m_{1} = a_{1} - b_{1} + n_{1}$$.



$\begin{array} { cccccc } & & & D & O & G \\ * & & & C & A & T \\ \hline & A & T & R & I & P \\ \end{array}$

In the second product shown above each letter represents a digit. Let $$a_{2}$$ be the maximum value for $$\overline{ATRIP}$$, $$b_{2}$$ be the minimum value for $$\overline{ATRIP}$$ and $$n_{2}$$ be all possible products of $$\: \overline{DOG} * \overline{CAT} = \overline{ATRIP}$$ and $$m_{2} = a_{2} - b_{2} + n_{2}$$. 

$\begin{array} { cccccc } & & & & I \\ * & & & A & M \\ * & & & & A \\ \hline & L & I & A & R \\ \end{array}$

In the third product shown above each letter represents a digit. Let $$a_{3}$$ be the maximum value for $$\overline{LIAR}$$, $$b_{3}$$ be the minimum value for $$\overline{LIAR}$$ and $$n_{3}$$ be all possible products of $$\: \overline{I} * \overline{AM} * \overline{A} = \overline{LIAR}$$ and $$m_{3} = a_{3} - b_{3} + n_{3}$$. 

Find: $$m_{1} + m_{2} + m_{3}$$.

Note: You can create a program(in any language) to find $$m_{1}$$, $$m_{2}$$ and $$m_{3}$$, but the program should not contain any predefined functions or procedures. That is you must create all functions and procedures and they should appear in the program, and not called from a library you created. For example, you could create your own maximum and minimum function for an array of integers and your own power function. 

I wrote a program $$A$$ that when executed gets the input and writes a program $$B$$ to solve cryptograms to a text file, then I saved the text file using a different extension, complied it and ran program $$B$$. 

So, for the first cryptogram you would just need to run program $$A$$ and save the text file(using a different extension) containing program $$B_{1}$$ and execute it, then run program $$A$$ again and save the text file(using a different extension) containing program $$B_{2}$$ and execute it, then run program $$A$$ again and save the text file(using a different extension) containing program $$B_{3}$$ and execute it.

I chose three cryptograms so that program $$A$$ can generate all three cryptograms as stated above. Writing three separate programs for each cryptogram would be tedious and that was not my intention. Essential, you just need to write program $$A$$. 

Assume I chose $$N$$ cryptograms. Write program $$A$$ to generate all $$N$$ cryptograms as stated above. 

Program $$A$$ is just a slight adjustment of the Program in the previous problem.



×