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}\). \(\)

\[ \begin{array} { cccccc } & & & O & N & E \\ + & & M & O & R & E \\ \hline & & T & I & M & E \\ \end{array} \]

In the third sum shown above each letter represents a digit. Let \( a_{3} \) be the maximum value for \(\overline{TIME}\), \( b_{3} \) be the minimum value for \(\overline{TIME}\) and \( n_{3} \) be all possible sums of \(\: \overline{ONE} + \overline{MORE} = \overline{TIME} \) 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.

×

Problem Loading...

Note Loading...

Set Loading...