# A computer science problem by Rocco Dalto

Computer Science Level pending

$\begin{array} { cccccc } & & & G & E & T \\ + & & M & A & I & L \\ \hline & T & O & D & A & Y \\ \end{array}$

In the sum shown above each letter represents a digit. Let $$a_{1}$$ be the maximum value for $$\overline{TODAY}$$, $$b_{1}$$ be the minimum value for $$\overline{TODAY}$$ and $$n_{1}$$ be all possible sums of $$\: \overline{GET} + \overline{MAIL} = \overline{TODAY}$$ and $$m_{1} = a_{1} - b_{1} + n_{1}$$.



$\begin{array} { cccccc } & T & H & I & S \\ & & & I & S \\ + & & & M & Y \\ \hline & T & I & M & E \\ \end{array}$

In the second sum shown above each letter represents a digit. Let $$a_{2}$$ be the maximum value for $$\overline{TIME}$$, $$b_{2}$$ be the minimum value for $$\overline{TIME}$$ and $$n_{2}$$ be all possible sums of $$\: \overline{THIS} + \overline{IS} + \overline{MY} = \overline{TIME}$$ and $$m_{2} = a_{2} - b_{2} + n_{2}$$.

Find: $$m_{2} - m_{1}$$.

Note: You can create a program(in any language) to find $$m_{1}$$ and $$m_{2}$$, 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.

Essentially, the problem is to write program $$A$$.

×