A computer science problem by Rocco Dalto

Computer Science Level pending

F O U R T W O O N E O N E \begin{array} { cccccc } & F & O & U & R \\ - & & T & W & O \\ - & & O & N & E \\ \hline & & O & N & E \\ \end{array}

In the cryptogram shown above each letter represents a digit. Let a 1 a_{1} be the maximum value for O N E \overline{ONE} , b 1 b_{1} be the minimum value for O N E \overline{ONE} and n 1 n_{1} be all possible values of F O U R T W O O N E = O N E \: \overline{FOUR} - \overline{TWO} - \overline{ONE} = \overline{ONE} and m 1 = a 1 b 1 + n 1 m_{1} = a_{1} - b_{1} + n_{1} , where the result O N E \overline{ONE} is a positive integer.

F O U R T W O T W O \begin{array} { cccccc } & & F & O & U & R \\ - & & & T & W & O \\ \hline & & & T & W & O \\ \end{array}

In the second cryptogram shown above each letter represents a digit. Let a 2 a_{2} be the maximum value for T W O \overline{TWO} , b 2 b_{2} be the minimum value for T W O \overline{TWO} and n 2 n_{2} be all possible values of F O U R T W O = T W O \: \overline{FOUR} - \overline{TWO} = \overline{TWO} and m 2 = a 2 b 2 + n 2 m_{2} = a_{2} - b_{2} + n_{2} , where the result T W O \overline{TWO} is a positive integer.

F I V E T W O O N E T W O \begin{array} { cccccc } & F & I & V & E \\ - & & T & W & O \\ - & & O & N & E \\ \hline & & T & W & O \\ \end{array}

In the third cryptogram shown above each letter represents a digit. Let a 3 a_{3} be the maximum value for T W O \overline{TWO} , b 3 b_{3} be the minimum value for T W O \overline{TWO} and n 3 n_{3} be all possible values of F I V E T W O O N E = T W O \: \overline{FIVE} - \overline{TWO} - \overline{ONE} = \overline{TWO} and m 3 = a 3 b 3 + n 3 m_{3} = a_{3} - b_{3} + n_{3} , where the result T W O \overline{TWO} is a positive integer.

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

Note: You can create a program(in any language) to find m 1 m_{1} , m 2 m_{2} and m 3 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 A that when executed gets the input and writes a program B B to solve cryptograms to a text file, then I saved the text file using a different extension, complied it and ran program B B .

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

I chose three cryptograms so that program A 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 A .

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

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

Refer to previous problem. . .


The answer is 1872.

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 28, 2017

I used Free Pascal to construct the program:

Program A : A:

program for_brillant;

uses mathunit;

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

 chararray = array[1 .. 1000] of char;

var myfile:text;

s:string;

n:longint;

numwords:longint;

hold:text;

sizeword:arraytype;

procedure getinput; var j:longint;

begin

writeln('Enter string of characters including - and =, but no spaces');

read(s);

n:= length(s);

writeln;

writeln('Enter number of words');

readln(numwords);

writeln;

writeln('Enter length of each word');

for j:= 1 to numwords do

begin

read(sizeword[j]);

end;

end;

procedure eliminate;

type darraytype = array[1 .. 300,1 .. 300] of char;

 strarray = array[1 .. 300] of string;

var j,k:longint;

notequal:boolean;

counter,counter2,total,total2,newtotal:longint;

w,z,y,x,p:chararray;

equal:boolean;

v:darraytype;

sum:strarray;

e,a,b,c,f:string;

begin

counter:= 0;

for j:= 1 to n - 1 do

begin

notequal:= true;

for k:= j + 1 to n do

begin

if (s[j] = s[k]) then

notequal:= false;

end;

if notequal and (s[j] <> '-') and (s[j] <> '=') then

begin

counter:= counter + 1;

w[counter]:= s[j];

end;

end;

total:= counter + 1;

w[total]:= s[n];

z[1]:= s[1];

counter:= 1;

for j:= 1 to n do

begin

if (s[j] = '-') or (s[j] = '=') then

begin

counter:= counter + 1;

z[counter]:= s[j + 1];

end;

end;

counter2:= 0;

for j:= 1 to counter - 1 do

begin

notequal:= true;

for k:= j + 1 to counter do

begin

if (z[j] = z[k]) then

notequal:= false;

end;

if notequal then

begin

counter2:= counter2 + 1;

y[counter2]:= z[j];

end;

end;

total2:= counter2 + 1;

y[total2]:= z[counter];

counter:= 0;

counter2:= 0;

for j:= 1 to total do

begin

notequal:= true;

for k:= 1 to total2 do

begin

if w[j] = y[k] then

begin

notequal:= false;

counter:= counter + 1;

x[counter]:= w[j];

end;

end;

if notequal then

begin

counter2:= counter2 + 1;

z[counter2]:= w[j];

end;

end;

assign(myfile, 'myfile3.txt');

rewrite(myfile);

writeln(myfile,'program for brillant 3;');

writeln(myfile,'type arraytype = array[1 .. 5000] of longint;');

writeln(myfile,'var z1:arraytype;');

writeln(myfile);

writeln(myfile);

writeln(myfile,'function LINTpower(base,exponent:longint):longint;');

writeln(myfile,'var n,product:longint;');

writeln(myfile);

writeln(myfile,'begin');

    writeln(myfile,'product:= 1;');

writeln(myfile,'for n:= 1 to exponent do');

writeln(myfile,'begin');

writeln(myfile,'product:= base * product;');

writeln(myfile,'end;');

    writeln(myfile,'LINTpower:= product;');

writeln(myfile,'end;');

writeln(myfile);

writeln(myfile);

writeln(myfile, 'function minnum(a:arraytype; last:longint):longint;');

writeln(myfile,'var j,n:longint;');

writeln(myfile,'small:longint;');

writeln(myfile);

  writeln(myfile,'begin');

        writeln(myfile,'small:= a[1];');

writeln(myfile,'for j:= 2 to last do');

writeln(myfile,'begin');

writeln(myfile,'if a[j] < small then');

        writeln(myfile,'small:= a[j];');

writeln(myfile,'end;');

writeln(myfile,'minnum:= small;');

    writeln(myfile,'end;');

    writeln(myfile);

writeln(myfile,'function maxnum(a:arraytype; last:longint):longint;');

writeln(myfile,'var j,n:longint;');

writeln(myfile,'large:longint;');

  writeln(myfile,'begin');

        writeln(myfile,'large:= a[1];');

writeln(myfile,'for j:= 2 to last do');

writeln(myfile,'begin');

writeln(myfile,'if a[j] > large then');

        writeln(myfile,'large:= a[j];');

writeln(myfile,'end;');

writeln(myfile,'maxnum:= large;');

    writeln(myfile,'end;');

    writeln(myfile);

writeln(myfile,'procedure getsum; ');

writeln(myfile);

write(myfile,'var ');

for j:= 1 to counter do

begin

write(myfile,x[j],',');

end;

for j:= 1 to counter2 do

begin

if j < counter2 then

write(myfile, z[j],',')

else

write(myfile, z[j]);

end;

write(myfile,':longint;');

writeln(myfile);

write(myfile,' bool:boolean;');

writeln(myfile);

write(myfile,' j1:longint;');

writeln(myfile);

write(myfile,' a1,a2,a3,answer:longint; ');

writeln(myfile, 'sum:arraytype;');

writeln(myfile);

writeln(myfile);

writeln(myfile,'begin');

writeln(myfile);

writeln(myfile,'bool:= false;');

writeln(myfile,'j1:= 1;');

for j:= 1 to counter do

begin

writeln(myfile,'for ', x[j],':= 1 to 9 do ');

writeln(myfile,'begin')

end;

for j:= 1 to counter2 do

begin

writeln(myfile,'for ', z[j],':= 0 to 9 do ' );

writeln(myfile,'begin');

end;

for j:= 1 to counter do

begin

p[j]:= x[j];

end;

for j:= 1 to counter2 do

begin

p[j + counter]:= z[j];

end;

newtotal:= counter + counter2;

write(myfile,' if ');

for j:= 1 to newtotal - 1 do

begin

for k:= j + 1 to newtotal do

begin

if k mod 5 = 0 then

write(myfile);

writeln(myfile);

if j < newtotal - 1 then

write(myfile, '(',p[j], ' <> ', p[k],') and ')

else

write(myfile, '(',p[j], ' <> ', p[k],')');

end;

end;

write(myfile, ' then');

writeln(myfile);

writeln(myfile, 'begin' );

assign(hold,'hold.txt');

rewrite(hold);

for j:= 1 to n do

begin

if (s[j] <> '-') and (s[j] <> '=') then

begin

write(hold,s[j]);

end;

end;

reset(hold);

for j:= 1 to numwords do

begin

for k:= 1 to sizeword[j] do

begin

read(hold,v[k,j]);

end;

end;

sum[1]:= '';

for j:= 1 to numwords do

begin

if j <= numwords - 1 then

write(myfile,'z1[',j,']:= ')

else

write(myfile,'sum[j1]:= ');

for k:= 1 to sizeword[j] do

begin

str(sizeword[j] - k,e);

if k < sizeword[j] then

sum[j]:= sum[j] + ' ' + v[k,j] + ' * lintpower(10,' + e + ') + '

else

sum[j]:= sum[j] + ' ' + v[k,j] + ' * lintpower(10,' + e + ')';

end;

write(myfile,sum[j],';');

writeln(myfile);

end;

{put condition and equation here}

write(myfile,' if ');

a:= '';

for k:= 1 to numwords do

begin

if k <= numwords - 2 then

begin

str(k,b);

a:= a + 'z1[' + b + '] - '

end

else

begin

str(numwords - 1,c);

b:= 'z1[' + c + ']';

end;

f:= 'sum[j1]';

end;

write(myfile, a + b, ' = ', f);

write(myfile,' then ');

writeln(myfile,'begin');

writeln(myfile,'bool:= true;');

writeln(myfile,'j1:= j1 + 1;');

writeln(myfile,'end;');

writeln(myfile,'end;');

close(hold);

writeln(myfile);

for j:= 1 to newtotal do

begin

writeln(myfile, 'end;');

end;

writeln(myfile);

writeln(myfile,'if bool then');

writeln(myfile,'begin');

writeln(myfile,'a3:= j1 - 1;');

writeln(myfile);

writeln(myfile,'a2:= maxnum(sum,a3);');

writeln(myfile,'a1:= minnum(sum,a3);');

writeln(myfile,'writeln(''max = '', a2);');

writeln(myfile,'writeln(''min = '', a1);');

writeln(myfile,'writeln(''n = '', a3);');

writeln(myfile,'answer:= a2 - a1 + a3;');

writeln(myfile,'writeln(''answer = '', answer);');

writeln(myfile,'end;');

writeln(myfile);

writeln(myfile,' end; ');

writeln(myfile);

writeln(myfile);

writeln(myfile,'begin');

writeln(myfile,'getsum;');

writeln(myfile,'readln;');

writeln(myfile,'end.');

close(myfile);

end;

begin

getinput;

eliminate;

readln;

end.

Now run program A A and enter the data for the first cryptogram. Program A A has now written program B 1 B_{1} to the textfile "myfile3.txt".

For program B 1 : B_{1}:

Go to text file "myfile3.txt" and save it with a different extension( I saved it using using cryptogramdiff.pas).

Program cryptogramdiff.pas is:

program for brillant 3;

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

var z1:arraytype;

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 getsum;

var f,t,o,u,r,w,n,e:longint;

bool:boolean;

j1:longint;

a1,a2,a3,answer:longint; sum:arraytype;

myfile:text; {added}

begin

assign(myfile,'justtest4.txt'); {added}

rewrite(myfile);

bool:= false;

j1:= 1;

for f:= 1 to 9 do

begin

for t:= 1 to 9 do

begin

for o:= 1 to 9 do

begin

for u:= 0 to 9 do

begin

for r:= 0 to 9 do

begin

for w:= 0 to 9 do

begin

for n:= 0 to 9 do

begin

for e:= 0 to 9 do

begin

if

(f <> t) and

(f <> o) and

(f <> u) and

(f <> r) and

(f <> w) and

(f <> n) and

(f <> e) and

(t <> o) and

(t <> u) and

(t <> r) and

(t <> w) and

(t <> n) and

(t <> e) and

(o <> u) and

(o <> r) and

(o <> w) and

(o <> n) and

(o <> e) and

(u <> r) and

(u <> w) and

(u <> n) and

(u <> e) and

(r <> w) and

(r <> n) and

(r <> e) and

(w <> n) and

(w <> e) and

(n <> e) then

begin

z1[1]:= f * lintpower(10,3) + o * lintpower(10,2) + u * lintpower(10,1) + r * lintpower(10,0);

z1[2]:= t * lintpower(10,2) + w * lintpower(10,1) + o * lintpower(10,0);

z1[3]:= o * lintpower(10,2) + n * lintpower(10,1) + e * lintpower(10,0);

sum[j1]:= o * lintpower(10,2) + n * lintpower(10,1) + e * lintpower(10,0);

if z1[1] - z1[2] - z1[3] = sum[j1] then begin

bool:= true;

writeln(myfile, z1[1],' - ',z1[2],' - ',z1[3],' = ',sum[j1]); {added}

j1:= j1 + 1;

end;

end;

end;

end;

end;

end;

end;

end;

end;

end;

if bool then

begin

a3:= j1 - 1;

a2:= maxnum(sum,a3);

a1:= minnum(sum,a3);

writeln('max = ', a2);

writeln('min = ', a1);

writeln('n = ', a3);

answer:= a2 - a1 + a3;

writeln('answer = ', answer);

end;

close(myfile);

end;

begin

getsum;

readln;

end.

Running cryptogramdiff.pas we obtain:

a 1 = 834 , b 1 = 207 , n 1 = 107 m 1 = 734 . a_{1} = 834, \: b_{1} = 207, \: n_{1} = 107 \implies m_{1} = \boxed{734}.

I added an option to cryptogramdiff.pas for writing the results to a file, where I inserted {added}.

The results are:

1604 - 286 - 659 = 659

1630 - 256 - 687 = 687

1634 - 256 - 689 = 689

1654 - 276 - 689 = 689

1735 - 207 - 764 = 764

1743 - 207 - 768 = 768

1745 - 207 - 769 = 769

1745 - 267 - 739 = 739

1749 - 237 - 756 = 756

1759 - 287 - 736 = 736

1763 - 247 - 758 = 758

1765 - 287 - 739 = 739

1765 - 297 - 734 = 734

1785 - 247 - 769 = 769

1793 - 257 - 768 = 768

1856 - 238 - 809 = 809

1864 - 258 - 803 = 803

1874 - 268 - 803 = 803

1876 - 208 - 834 = 834

1876 - 258 - 809 = 809

1509 - 345 - 582 = 582

1509 - 365 - 572 = 572

1509 - 385 - 562 = 562

1624 - 306 - 659 = 659

1640 - 326 - 657 = 657

1640 - 386 - 627 = 627

1650 - 396 - 627 = 627

1670 - 386 - 642 = 642

1680 - 376 - 652 = 652

1680 - 396 - 642 = 642

1684 - 326 - 679 = 679

1690 - 346 - 672 = 672

1690 - 386 - 652 = 652

1692 - 376 - 658 = 658

1745 - 327 - 709 = 709

1759 - 307 - 726 = 726

1759 - 347 - 706 = 706

1765 - 307 - 729 = 729

1765 - 347 - 709 = 709

1785 - 367 - 709 = 709

1795 - 387 - 704 = 704

1537 - 485 - 526 = 526

1539 - 405 - 567 = 567

1539 - 485 - 527 = 527

1563 - 405 - 579 = 579

1569 - 405 - 582 = 582

1583 - 425 - 579 = 579

1597 - 425 - 586 = 586

1652 - 436 - 608 = 608

1672 - 456 - 608 = 608

1682 - 476 - 603 = 603

1690 - 436 - 627 = 627

1692 - 476 - 608 = 608

1692 - 486 - 603 = 603

1307 - 543 - 382 = 382

1307 - 583 - 362 = 362

1309 - 573 - 368 = 368

1347 - 563 - 392 = 392

1367 - 583 - 392 = 392

1430 - 574 - 428 = 428

1438 - 504 - 467 = 467

1462 - 504 - 479 = 479

1462 - 584 - 439 = 439

1468 - 594 - 437 = 437

1470 - 534 - 468 = 468

1470 - 594 - 438 = 438

1472 - 534 - 469 = 469

1490 - 524 - 483 = 483

1490 - 534 - 478 = 478

1498 - 574 - 462 = 462

1230 - 652 - 289 = 289

1230 - 682 - 274 = 274

1240 - 682 - 279 = 279

1250 - 672 - 289 = 289

1258 - 672 - 293 = 293

1270 - 682 - 294 = 294

1309 - 653 - 328 = 328

1359 - 603 - 378 = 378

1387 - 603 - 392 = 392

1438 - 624 - 407 = 407

1452 - 634 - 409 = 409

1458 - 604 - 427 = 427

1472 - 654 - 409 = 409

1482 - 604 - 439 = 439

1490 - 634 - 428 = 428

1498 - 624 - 437 = 437

1240 - 762 - 239 = 239

1250 - 782 - 234 = 234

1254 - 782 - 236 = 236

1260 - 742 - 259 = 259

1260 - 782 - 239 = 239

1260 - 792 - 234 = 234

1280 - 742 - 269 = 269

1280 - 752 - 264 = 264

1280 - 762 - 259 = 259

1290 - 782 - 254 = 254

1294 - 782 - 256 = 256

1359 - 703 - 328 = 328

1359 - 743 - 308 = 308

1369 - 753 - 308 = 308

1395 - 703 - 346 = 346

1395 - 743 - 326 = 326

1395 - 783 - 306 = 306

1246 - 832 - 207 = 207

1256 - 842 - 207 = 207

1274 - 802 - 236 = 236

1296 - 802 - 247 = 247

Now run program A A and enter the data for the second cryptogram. Program A A has now written program B 2 B_{2} to the textfile "myfile3.txt".

For program B 2 : B_{2}:

Go to text file "myfile3.txt" and save it with a different extension( I saved it using using cryptogramdiff2.pas).

Program cryptogramdiff2.pas is:

program for brillant 3;

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

var z1:arraytype;

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 getsum;

var f,t,u,r,w,o:longint;

bool:boolean;

j1:longint;

a1,a2,a3,answer:longint; sum:arraytype;

myfile:text; {added}

begin

assign(myfile,'justtest5.txt'); {added}

rewrite(myfile);

bool:= false;

j1:= 1;

for f:= 1 to 9 do

begin

for t:= 1 to 9 do

begin

for u:= 0 to 9 do

begin

for r:= 0 to 9 do

begin

for w:= 0 to 9 do

begin

for o:= 0 to 9 do

begin

if

(f <> t) and

(f <> u) and

(f <> r) and

(f <> w) and

(f <> o) and

(t <> u) and

(t <> r) and

(t <> w) and

(t <> o) and

(u <> r) and

(u <> w) and

(u <> o) and

(r <> w) and

(r <> o) and

(w <> o) then

begin

z1[1]:= f * lintpower(10,3) + o * lintpower(10,2) + u * lintpower(10,1) + r * lintpower(10,0);

z1[2]:= t * lintpower(10,2) + w * lintpower(10,1) + o * lintpower(10,0);

sum[j1]:= t * lintpower(10,2) + w * lintpower(10,1) + o * lintpower(10,0);

if z1[1] - z1[2] = sum[j1] then begin

bool:= true;

writeln(myfile, z1[1],' - ',z1[2],' = ', sum[j1]); {added}

j1:= j1 + 1;

end;

end;

end;

end;

end;

end;

end;

end;

if bool then

begin

a3:= j1 - 1;

a2:= maxnum(sum,a3);

a1:= minnum(sum,a3);

writeln('max = ', a2);

writeln('min = ', a1);

writeln('n = ', a3);

answer:= a2 - a1 + a3;

writeln('answer = ', answer);

end;

close(myfile);

end;

begin

getsum;

readln;

end.

Running cryptogramdiff2.pas we obtain:

a 2 = 938 , b 2 = 734 , n 2 = 7 m 2 = 211 . a_{2} = 938, \: b_{2} = 734, \: n_{2} = 7 \implies m_{2} = \boxed{211}.

I added an option to cryptogramdiff2.pas for writing the results to a file, where I inserted {added}.

The results are:

1530 - 765 = 765

1468 - 734 = 734

1734 - 867 = 867

1672 - 836 = 836

1692 - 846 = 846

1856 - 928 = 928

1876 - 938 = 938

Now run program A A and enter the data for the second cryptogram. Program A A has now written program B 3 B_{3} to the textfile "myfile3.txt".

For program B 3 : B_{3}:

Go to text file "myfile3.txt" and save it with a different extension( I saved it using using cryptogramdiff3.pas).

Program cryptogramdiff3.pas is:

program for brillant 3;

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

var z1:arraytype;

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 getsum;

var f,t,o,i,v,n,e,w:longint;

bool:boolean;

j1:longint;

a1,a2,a3,answer:longint; sum:arraytype;

myfile:text; {added}

begin

assign(myfile,'justtest6.txt'); {added}

rewrite(myfile);

bool:= false;

j1:= 1;

for f:= 1 to 9 do

begin

for t:= 1 to 9 do

begin

for o:= 1 to 9 do

begin

for i:= 0 to 9 do

begin

for v:= 0 to 9 do

begin

for n:= 0 to 9 do

begin

for e:= 0 to 9 do

begin

for w:= 0 to 9 do

begin

if

(f <> t) and

(f <> o) and

(f <> i) and

(f <> v) and

(f <> n) and

(f <> e) and

(f <> w) and

(t <> o) and

(t <> i) and

(t <> v) and

(t <> n) and

(t <> e) and

(t <> w) and

(o <> i) and

(o <> v) and

(o <> n) and

(o <> e) and

(o <> w) and

(i <> v) and

(i <> n) and

(i <> e) and

(i <> w) and

(v <> n) and

(v <> e) and

(v <> w) and

(n <> e) and

(n <> w) and

(e <> w) then

begin

z1[1]:= f * lintpower(10,3) + i * lintpower(10,2) + v * lintpower(10,1) + e * lintpower(10,0);

z1[2]:= t * lintpower(10,2) + w * lintpower(10,1) + o * lintpower(10,0);

z1[3]:= o * lintpower(10,2) + n * lintpower(10,1) + e * lintpower(10,0);

sum[j1]:= t * lintpower(10,2) + w * lintpower(10,1) + o * lintpower(10,0);

if z1[1] - z1[2] - z1[3] = sum[j1] then begin

bool:= true;

writeln(myfile,z1[1],' - ',z1[2],' - ',z1[3],' = ',sum[j1]); {added}

j1:= j1 + 1;

end;

end;

end;

end;

end;

end;

end;

end;

end;

end;

if bool then

begin

a3:= j1 - 1;

a2:= maxnum(sum,a3);

a1:= minnum(sum,a3);

writeln('max = ', a2);

writeln('min = ', a1);

writeln('n = ', a3);

answer:= a2 - a1 + a3;

writeln('answer = ', answer);

end;

close(myfile);

end;

begin

getsum;

readln;

end.

Running cryptogramdiff3.pas we obtain:

a 3 = 985 , b 3 = 235 , n 3 = 177 m 3 = 927 . a_{3} = 985, \: b_{3} = 235, \: n_{3} = 177 \implies m_{3} = \boxed{927}.

I added an option to cryptogramdiff3.pas for writing the results to a file, where I inserted {added}.

The results are:

1046 - 235 - 576 = 235

1048 - 235 - 578 = 235

1049 - 235 - 579 = 235

1063 - 245 - 573 = 245

1068 - 245 - 578 = 245

1069 - 245 - 579 = 245

1064 - 235 - 594 = 235

1067 - 235 - 597 = 235

1068 - 235 - 598 = 235

1073 - 265 - 543 = 265

1078 - 265 - 548 = 265

1079 - 265 - 549 = 265

1073 - 245 - 583 = 245

1076 - 245 - 586 = 245

1079 - 245 - 589 = 245

1084 - 275 - 534 = 275

1086 - 275 - 536 = 275

1089 - 275 - 539 = 275

1083 - 245 - 593 = 245

1086 - 245 - 596 = 245

1087 - 245 - 597 = 245

1093 - 275 - 543 = 275

1096 - 275 - 546 = 275

1098 - 275 - 548 = 275

1260 - 345 - 570 = 345

1268 - 345 - 578 = 345

1269 - 345 - 579 = 345

1274 - 385 - 504 = 385

1276 - 385 - 506 = 385

1279 - 385 - 509 = 385

1270 - 365 - 540 = 365

1278 - 365 - 548 = 365

1279 - 365 - 549 = 365

1270 - 345 - 580 = 345

1276 - 345 - 586 = 345

1279 - 345 - 589 = 345

1280 - 345 - 590 = 345

1286 - 345 - 596 = 345

1287 - 345 - 597 = 345

1290 - 375 - 540 = 375

1296 - 375 - 546 = 375

1298 - 375 - 548 = 375

1372 - 405 - 562 = 405

1378 - 405 - 568 = 405

1379 - 405 - 569 = 405

1382 - 405 - 572 = 405

1386 - 405 - 576 = 405

1389 - 405 - 579 = 405

1392 - 405 - 582 = 405

1396 - 405 - 586 = 405

1397 - 405 - 587 = 405

1734 - 605 - 524 = 605

1738 - 605 - 528 = 605

1739 - 605 - 529 = 605

1742 - 605 - 532 = 605

1748 - 605 - 538 = 605

1749 - 605 - 539 = 605

1780 - 625 - 530 = 625

1784 - 625 - 534 = 625

1789 - 625 - 539 = 625

1792 - 645 - 502 = 645

1793 - 645 - 503 = 645

1798 - 645 - 508 = 645

1790 - 635 - 520 = 635

1794 - 635 - 524 = 635

1798 - 635 - 528 = 635

1790 - 625 - 540 = 625

1793 - 625 - 543 = 625

1798 - 625 - 548 = 625

1792 - 605 - 582 = 605

1793 - 605 - 583 = 605

1794 - 605 - 584 = 605

1820 - 645 - 530 = 645

1827 - 645 - 537 = 645

1829 - 645 - 539 = 645

1840 - 635 - 570 = 635

1842 - 635 - 572 = 635

1849 - 635 - 579 = 635

1840 - 625 - 590 = 625

1843 - 625 - 593 = 625

1847 - 625 - 597 = 625

1890 - 675 - 540 = 675

1892 - 675 - 542 = 675

1893 - 675 - 543 = 675

1902 - 685 - 532 = 685

1904 - 685 - 534 = 685

1907 - 685 - 537 = 685

1930 - 675 - 580 = 675

1932 - 675 - 582 = 675

1934 - 675 - 584 = 675

1940 - 685 - 570 = 685

1942 - 685 - 572 = 685

1943 - 685 - 573 = 685

1934 - 705 - 524 = 705

1936 - 705 - 526 = 705

1938 - 705 - 528 = 705

1942 - 705 - 532 = 705

1946 - 705 - 536 = 705

1948 - 705 - 538 = 705

1980 - 725 - 530 = 725

1984 - 725 - 534 = 725

1986 - 725 - 536 = 725

2016 - 735 - 546 = 735

2018 - 735 - 548 = 735

2019 - 735 - 549 = 735

2043 - 765 - 513 = 765

2048 - 765 - 518 = 765

2049 - 765 - 519 = 765

2061 - 735 - 591 = 735

2064 - 735 - 594 = 735

2068 - 735 - 598 = 735

2081 - 745 - 591 = 745

2083 - 745 - 593 = 745

2086 - 745 - 596 = 745

2104 - 785 - 534 = 785

2106 - 785 - 536 = 785

2109 - 785 - 539 = 785

2130 - 795 - 540 = 795

2136 - 795 - 546 = 795

2138 - 795 - 548 = 795

2130 - 785 - 560 = 785

2134 - 785 - 564 = 785

2139 - 785 - 569 = 785

2160 - 785 - 590 = 785

2163 - 785 - 593 = 785

2164 - 785 - 594 = 785

2146 - 805 - 536 = 805

2147 - 805 - 537 = 805

2149 - 805 - 539 = 805

2174 - 835 - 504 = 835

2176 - 835 - 506 = 835

2179 - 835 - 509 = 835

2173 - 805 - 563 = 805

2174 - 805 - 564 = 805

2179 - 805 - 569 = 805

2193 - 845 - 503 = 845

2196 - 845 - 506 = 845

2197 - 845 - 507 = 845

2304 - 895 - 514 = 895

2306 - 895 - 516 = 895

2307 - 895 - 517 = 895

2301 - 865 - 571 = 865

2304 - 865 - 574 = 865

2309 - 865 - 579 = 865

2310 - 875 - 560 = 875

2314 - 875 - 564 = 875

2319 - 875 - 569 = 875

2340 - 875 - 590 = 875

2341 - 875 - 591 = 875

2346 - 875 - 596 = 875

2360 - 895 - 570 = 895

2361 - 895 - 571 = 895

2364 - 895 - 574 = 895

2370 - 915 - 540 = 915

2376 - 915 - 546 = 915

2378 - 915 - 548 = 915

2371 - 905 - 561 = 905

2374 - 905 - 564 = 905

2378 - 905 - 568 = 905

2381 - 905 - 571 = 905

2384 - 905 - 574 = 905

2386 - 905 - 576 = 905

2403 - 915 - 573 = 915

2406 - 915 - 576 = 915

2408 - 915 - 578 = 915

2431 - 965 - 501 = 965

2437 - 965 - 507 = 965

2438 - 965 - 508 = 965

2460 - 975 - 510 = 975

2463 - 975 - 513 = 975

2468 - 975 - 518 = 975

2471 - 985 - 501 = 985

2473 - 985 - 503 = 985

2476 - 985 - 506 = 985

2480 - 975 - 530 = 975

2481 - 975 - 531 = 975

2486 - 975 - 536 = 975

m 1 + m 2 + m 3 = 1872 . \therefore m_{1} + m_{2} + m_{3} = \boxed{1872}.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...