# A computer science problem by Rocco Dalto

Computer Science Level pending

Let $$+$$ and $$*$$ be operations of addition and multiplication of integers respectively.

$YOU + ARE * A = PEST$

In the cryptogram shown above each letter represents a digit. Let $$a_{1}$$ be the maximum value for $$\overline{PEST}$$, $$b_{1}$$ be the minimum value for $$\overline{PEST}$$ and $$n_{1}$$ be all possible values of $$\: \overline{YOU} + \overline{ARE} * \overline{A} = \overline{PEST}$$ and $$m_{1} = a_{1} - b_{1} + n_{1}$$.

$YOU + ARE * A = LIAR$

In the second cryptogram shown above each letter represents a digit. Let $$a_{2}$$ be the maximum value for $$\overline{LIAR}$$, $$b_{2}$$ be the minimum value for $$\overline{LIAR}$$ and $$n_{2}$$ be all possible values of $$\: \overline{YOU} + \overline{ARE} * \overline{A} = \overline{LIAR}$$ and $$m_{2} = a_{2} - b_{2} + n_{2}$$.

$I * LOVE + MY = PIZZA$

In the third cryptogram shown above each letter represents a digit. Let $$a_{3}$$ be the maximum value for $$\overline{PIZZA}$$, $$b_{3}$$ be the minimum value for $$\overline{PIZZA}$$ and $$n_{3}$$ be all possible values of $$\: \overline{I} * \overline{LOVE} + \overline{MY} = \overline{PIZZA}$$ 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.



×