Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫  π  -¹ ² ³ °

You are not logged in.

## #1 2017-07-17 11:14:24

ProgrammerCam
Member
Registered: 2017-07-17
Posts: 2

### Solve this: ALFA + BETA + GAMA = DELTA Replace letters with digits

I was just wondering if anyone on this site uses programming languages to solve these types of challenges.
I have worked this one out and found a few more solutions than the https://www.mathsisfun.com/puzzles/alfa-beta-gama-delta.html solution gives.
my solutions are:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

5325 + 0465 + 8575 = 14365
5325 + 0495 + 8575 = 14395
5625 + 0435 + 8575 = 14635
5625 + 0495 + 8575 = 14695
5925 + 0435 + 8575 = 14935
5925 + 0465 + 8575 = 14965
5235 + 0475 + 8565 = 14275
5235 + 0495 + 8565 = 14295
5735 + 0425 + 8565 = 14725
5735 + 0495 + 8565 = 14795
5935 + 0425 + 8565 = 14925
5935 + 0475 + 8565 = 14975
5265 + 0475 + 8535 = 14275
5265 + 0495 + 8535 = 14295
5765 + 0425 + 8535 = 14725
5765 + 0495 + 8535 = 14795
5965 + 0425 + 8535 = 14925
5965 + 0475 + 8535 = 14975
5375 + 0465 + 8525 = 14365
5375 + 0495 + 8525 = 14395
5675 + 0435 + 8525 = 14635
5675 + 0495 + 8525 = 14695
5975 + 0435 + 8525 = 14935
5975 + 0465 + 8525 = 14965
5305 + 2475 + 6595 = 14375
5305 + 2485 + 6595 = 14385
5705 + 2435 + 6595 = 14735
5705 + 2485 + 6595 = 14785
5805 + 2435 + 6595 = 14835
5805 + 2475 + 6595 = 14875
5395 + 2475 + 6505 = 14375
5395 + 2485 + 6505 = 14385
5795 + 2435 + 6505 = 14735
5795 + 2485 + 6505 = 14785
5895 + 2435 + 6505 = 14835
5895 + 2475 + 6505 = 14875
5305 + 6475 + 2595 = 14375
5305 + 6485 + 2595 = 14385
5705 + 6435 + 2595 = 14735
5705 + 6485 + 2595 = 14785
5805 + 6435 + 2595 = 14835
5805 + 6475 + 2595 = 14875
5395 + 6475 + 2505 = 14375
5395 + 6485 + 2505 = 14385
5795 + 6435 + 2505 = 14735
5795 + 6485 + 2505 = 14785
5895 + 6435 + 2505 = 14835
5895 + 6475 + 2505 = 14875
5325 + 8465 + 0575 = 14365
5325 + 8495 + 0575 = 14395
5625 + 8435 + 0575 = 14635
5625 + 8495 + 0575 = 14695
5925 + 8435 + 0575 = 14935
5925 + 8465 + 0575 = 14965
5235 + 8475 + 0565 = 14275
5235 + 8495 + 0565 = 14295
5735 + 8425 + 0565 = 14725
5735 + 8495 + 0565 = 14795
5935 + 8425 + 0565 = 14925
5935 + 8475 + 0565 = 14975
5265 + 8475 + 0535 = 14275
5265 + 8495 + 0535 = 14295
5765 + 8425 + 0535 = 14725
5765 + 8495 + 0535 = 14795
5965 + 8425 + 0535 = 14925
5965 + 8475 + 0535 = 14975
5375 + 8465 + 0525 = 14365
5375 + 8495 + 0525 = 14395
5675 + 8435 + 0525 = 14635
5675 + 8495 + 0525 = 14695
5975 + 8435 + 0525 = 14935
5975 + 8465 + 0525 = 14965

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I used C++ to solve it like this:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include <iostream>

using namespace std;

int main(){

//initializing variables at 0 so they can start counting up
int a = 0;
int b = 0;
int d = 0;
int e = 0;
int f = 0;
int g = 0;
int l = 0;
int m = 0;
int t = 0;

while(a != -1){
//this checks to make sure each variable is unique
if((a!=b) && (a!=d) && (a!=e) && (a!=f) && (a!=g) && (a!=l) && (a!=m) && (a!=t)){
if((b!=d) && (b!=e) && (b!=f) && (b!=g) && (b!=l) && (b!=m) && (b!=t)){
if((d!=e) && (d!=f) && (d!=g) && (d!=l) && (d!=m) && (d!=t)){
if((e!=f) && (e!=g) && (e!=l) && (e!=m) && (e!=t)){
if((f!=g) && (f!=l) && (f!=m) && (f!=t)){
if((g!=l) && (g!=m) && (g!=t)){
if((l!=m) && (l!=t)){
if((m!=t)){

//this creates place holder variables to make the math easier and quicker
int ALFA = ((a*1000) + (l*100) + (f*10) + (a*1));
int BETA = ((b*1000) + (e*100) + (t*10) + (a*1));
int GAMA = ((g*1000) + (a*100) + (m*10) + (a*1));
int DELTA = ((d*10000) + (e*1000) + (l*100) + (t*10) + (a*1));

//this checks to see if the initial requirement is true and outputs correct sequences
if(ALFA + BETA + GAMA == DELTA){
cout << a << l << f << a;
cout << " + ";
cout << b << e << t << a;
cout << " + ";
cout << g << a << m << a;
cout << " = ";
cout << d << e << l << t << a;
}
}
}
}
}
}
}
}
}
//This part of the code counts from 0 to the highest number possible with the amount of variables (in this case 9 variables) it then terminates with a -1
if(t < 9){
t++;
}else if((t == 9) && (m < 9)){
m++;
t = 0;
}else if((t == 9) && (m == 9) && (l< 9)){
l++;
m = 0;
t = 0;
}else if((t == 9) && (m == 9) && (l == 9) && (g < 9)){
g++;
l = 0;
m = 0;
t = 0;
}
else if((t == 9) && (m == 9) && (l == 9) && (g == 9) && (f < 9)){
f++;
g = 0;
l = 0;
m = 0;
t = 0;
}else if((t == 9) && (m == 9) && (l == 9) && (g == 9) && (f == 9) && (e < 9)){
e++;
f = 0;
g = 0;
l = 0;
m = 0;
t = 0;
}
else if((t == 9) && (m == 9) && (l == 9) && (g == 9) && (f == 9) && (e == 9) && (d < 9)){
d++;
e = 0;
f = 0;
g = 0;
l = 0;
m = 0;
t = 0;
}else if((t == 9) && (m == 9) && (l == 9) && (g == 9) && (f == 9) && (e == 9) && (d == 9) && (b < 9)){
b++;
d = 0;
e = 0;
f = 0;
g = 0;
l = 0;
m = 0;
t = 0;
}
else if((t == 9) && (m == 9) && (l == 9) && (g == 9) && (f == 9) && (e == 9) && (d == 9) && (b == 9) && (a < 9)){
a++;
b = 0;
d = 0;
e = 0;
f = 0;
g = 0;
l = 0;
m = 0;
t = 0;
}
else if(a == 9){
a = -1;
b = 0;
d = 0;
e = 0;
f = 0;
g = 0;
l = 0;
m = 0;
t = 0;
}
}
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Anyone know how to do it better or faster?

Offline

## #2 2017-07-17 14:50:21

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,860
Website

### Re: Solve this: ALFA + BETA + GAMA = DELTA Replace letters with digits

I use programming languages to solve these problems.

Yes, you could also use a constraint solver to do this for you.

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline