By Kardi Teknomo, PhD.


< Previous | Content | Next >

Share this: Google+

CryptArithmetic Problem: BASE + BALL = GAMES

This following puzzle is the interesting CryptArithmetic Problem:

BASE BALL GAMES CryptArithmetic Problem and Solution

How to solve the above challenge?

We put the letter as equality constraints
Expression1 = 1000*B + 100*A + 10*S + E
Expression2 = 1000*B + 100*A + 10*L + L
Expression3 = 10000*G + 1000*A + 100*M + 10*E + S
If (Expression3 ==Expression1 + Expression2) then
Report the value of {B, A, S, E, L, G, M}

We do permutation of digit 0 to 9 and then compute the above expression. Matlab code below gives all the possible solutions.

function report=BASEBALLGAMES

digit=0:9;
P=perms(digit);
k=0;
for i=1:size(P,1)
v=P(i,:);

% evaluate expression BASE + BALL = GAMES
exp1=v(1)*1000+v(2)*100+v(3)*10+v(4); % BASE
exp2=v(1)*1000+v(2)*100+v(5)*10+v(5); % BALL
exp3=v(6)*10000+v(2)*1000+v(7)*100+v(4)*10+v(3); % GAMES
if exp1+exp2==exp3,
k=k+1;
report(k,:)=v(1:7); % = [b, a, s, e, l, g, m]
end
end
report=unique(report,'rows');

Solutions:

If we allow G to be zero, the solutions are not unique. Below are all the 3 possible solutions.
{B=2, A=4, S=6, E=1, L=5, G=0, M=9}
{B=2, A=4, S=8, E=3, L=5, G=0, M=9}
{B=7, A=4, S=8, E=3, L=5, G=1, M=9}

               2461         2483            7483         BASE
2455 2455 7455 BALL
--------- + ---------- + ---------- + --------- +
04916 04938 14938 GAMES


If G has to be non-zero digit, the solution is unique.

< Previous | Content | Next >