A number theory problem by Rocco Dalto

Number Theory Level pending

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

In the sum shown above each letter represents a digit. Let a a be the maximum value for T I M E \overline{TIME} , b b be the minimum value for T I M E \overline{TIME} and n n be all possible sums of O N E + M O R E = T I M E \: \overline{ONE} + \overline{MORE} = \overline{TIME}

Find a b + n a - b + n .

Note: You can create a program(in any language) to find the above value a b + n a - b + n , 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.


The answer is 7212.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Rocco Dalto
Feb 15, 2017

I used Free Pascal to write the code below.

program for_brillant2;

type arraytype = array[1 .. 300] of longint;

var myfile:text; {Not necessary. Just adding a file to list all possible sums.}

function lintpower(base,exponent:longint):longint;

var n,product:longint;

begin

 product:= 1;

for n:= 1 to exponent do

begin

product:= base * product;

end;

    lintpower:= product;

end;

function minnum(a:arraytype; last:longint):longint;

var j,n:longint;

small:longint;

  begin

        small:= a[1];

for j:= 2 to last do

begin

  if a[j] < small then

        small:= a[j];

end;

minnum:= small;

    end;

function maxnum(a:arraytype; last:longint):longint;

var j,n:longint;

large:longint;

  begin

        large:= a[1];

for j:= 2 to last do

begin

if a[j] > large then

        large:= a[j];

end;

maxnum:= large;

    end;

procedure getlist2;

var o,n,e,m,t,r,i,answer,a1,a2,a,b,total,j:longint;

      sum:arraytype;

      bool:boolean;

begin

assign(myfile,'brillant2.txt');

rewrite(myfile);

bool:= false;

j:= 1;

for o:= 1 to 9 do

begin

for n:= 0 to 9 do

begin

for e:= 0 to 9 do

begin

for m:= 1 to 9 do

begin

for t:= 1 to 9 do

begin

for r:= 0 to 9 do

begin

for i:= 0 to 9 do

begin

if (o <> n) and (o <> e) and (o <> m) and (o <> t) and (o <> r) and (o <> i)

and (n <> e) and (n <> m) and (n <> t) and (n <> r)

and (n <> i) and (e <> m) and (e <> t) and (e <> r)

and (e <> i) and (m <> t) and (m <> r) and (m <> i)

and (t <> r) and (t <> i) and (r <> i)

then

begin

a1:= o * lintpower(10,2) + n * 10 + e;

a2:= m * lintpower(10,3) + o * lintpower(10,2) + r * 10 + e;

sum[j]:= t * lintpower(10,3) + i * lintpower(10,2) + m * 10  + e;

 if a1 + a2 = sum[j] then

begin

bool:= true;

writeln(myfile, a1,' + ',a2,' = ',sum[j]); {not needed- just listing sums}

 j:= j + 1;

end;

end;

end;

end;

end;

end;

end;

end;

end;

if bool then

begin

total:= j - 1;

a:= maxnum(sum,total);

b:= minnum(sum,total);

answer:= a - b + total;

 writeln('max = ', a);

 writeln('min = ', b);

 writeln('n = ', total);

 writeln('answer = ', answer);

  end;

close(myfile);

end;

begin

getlist2;

readln;

end.

Running the program above we obtain:

a = 9480 , b = 2310 , n = 42 a b + n = 7212 . a = 9480, \: b = 2310, \: n = 42 \implies \boxed{a - b + n = 7212}.

Although it's not necessary to this problem, the list of all possible sums are:

540 + 2580 = 3120

560 + 3570 = 4130

570 + 3560 = 4130

580 + 2540 = 3120

610 + 4630 = 5240

610 + 8670 = 9280

630 + 4610 = 5240

630 + 7640 = 8270

630 + 8650 = 9280

640 + 1670 = 2310

640 + 7630 = 8270

650 + 8630 = 9280

670 + 1640 = 2310

670 + 8610 = 9280

720 + 5730 = 6450

720 + 8760 = 9480

730 + 1780 = 2510

730 + 5720 = 6450

730 + 8750 = 9480

740 + 2780 = 3520

750 + 8730 = 9480

760 + 8720 = 9480

780 + 1730 = 2510

780 + 2740 = 3520

810 + 3820 = 4630

810 + 4830 = 5640

820 + 3810 = 4630

830 + 4810 = 5640

850 + 1860 = 2710

860 + 1850 = 2710

910 + 3920 = 4830

910 + 4930 = 5840

910 + 5940 = 6850

910 + 6950 = 7860

920 + 3910 = 4830

920 + 5930 = 6850

920 + 6940 = 7860

930 + 4910 = 5840

930 + 5920 = 6850

940 + 5910 = 6850

940 + 6920 = 7860

950 + 6910 = 7860

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...