# Letter / Number puzzle

• Jun 10th 2010, 09:12 AM
FoxEcho
Letter / Number puzzle
Hi,
I'm trying to solve this puzzle for a geocaching challenge:

AB + CD = EF
AG + CE = FH
BF - GE = AJ
A>C
Numbers to be used are 1 to 9

Thanks,
FoxEcho
• Jun 10th 2010, 09:13 AM
Unknown008
Just a quick question, does AB mean A times B or a number with digits AB?
• Jun 10th 2010, 09:19 AM
FoxEcho
AB is a number with digits AB,
and so on and so forth.

FE
• Jun 10th 2010, 09:44 AM
hungthinh92
Quote:

Originally Posted by FoxEcho
Hi,
I'm trying to solve this puzzle for a geocaching challenge:

AB + CD = EF
AG + CE = FH
BF - GE = AJ
A>C
Numbers to be used are 1 to 9

Thanks,
FoxEcho

Do they need to be different. I mean A≠b≠C
• Jun 10th 2010, 09:45 AM
Unknown008
I guess so, if it was not, the question wouldn't use different letters to represent the digits.
• Jun 10th 2010, 09:48 AM
hungthinh92
Quote:

Originally Posted by Unknown008
I guess so, if it was not, the question wouldn't use different letters to represent the digits.

Ommm silly me! I just ate lunch, so my brain starts working again (Nerd)
• Jun 10th 2010, 09:48 AM
FoxEcho
Yes, all numbers are different.
Numbers 1 to 9 are represented by letters A to J
(the letter I has not been used to avoid confusion with the number 1).
FE
• Jun 10th 2010, 10:13 AM
undefined
The lazy programmer's solution, in Java:

Code:

```public class NumPuzz1 {     public static void main(String[] args) {         long time=System.currentTimeMillis();         int a,b,c,d,e,f,g,h,j;         for(a=2;a<10;a++)         for(b=1;b<10;b++) if(b!=a)         for(c=1;c<a;c++)  if(c!=b)         for(d=1;d<10;d++) if(d!=a && d!=b && d!=c)         for(e=1;e<10;e++) if(e!=a && e!=b && e!=c && e!=d)         for(f=1;f<10;f++) if(f!=a && f!=b && f!=c && f!=d && f!=e)         for(g=1;g<10;g++) if(g!=a && g!=b && g!=c && g!=d && g!=e && g!=f)         for(h=1;h<10;h++) if(h!=a && h!=b && h!=c && h!=d && h!=e && h!=f && h!=g)         for(j=1;j<10;j++) if(j!=a && j!=b && j!=c && j!=d && j!=e && j!=f && j!=g && j!=h)             if(10*a+b + 10*c+d == 10*e+f && 10*a+g + 10*c+e == 10*f+h && 10*b+f - (10*g+e) == 10*a+j)                 System.out.println(a+","+b+","+c+","+d+","+e+","+f+","+g+","+h+","+j);         System.out.println("Elapsed: "+((System.currentTimeMillis()-time)/1000.0)+" seconds");     } }```
Output:

Code:

```3,6,1,8,5,4,2,7,9 Elapsed: 0.047 seconds```
• Jun 10th 2010, 10:17 AM
hungthinh92
Quote:

Originally Posted by undefined
The lazy programmer's solution, in Java:

Code:

```public class NumPuzz1 {     public static void main(String[] args) {         long time=System.currentTimeMillis();         int a,b,c,d,e,f,g,h,j;         for(a=2;a<10;a++)         for(b=1;b<10;b++) if(b!=a)         for(c=1;c<a;c++)  if(c!=b)         for(d=1;d<10;d++) if(d!=a && d!=b && d!=c)         for(e=1;e<10;e++) if(e!=a && e!=b && e!=c && e!=d)         for(f=1;f<10;f++) if(f!=a && f!=b && f!=c && f!=d && f!=e)         for(g=1;g<10;g++) if(g!=a && g!=b && g!=c && g!=d && g!=e && g!=f)         for(h=1;h<10;h++) if(h!=a && h!=b && h!=c && h!=d && h!=e && h!=f && h!=g)         for(j=1;j<10;j++) if(j!=a && j!=b && j!=c && j!=d && j!=e && j!=f && j!=g && j!=h)             if(10*a+b + 10*c+d == 10*e+f && 10*a+g + 10*c+e == 10*f+h && 10*b+f - (10*g+e) == 10*a+j)                 System.out.println(a+","+b+","+c+","+d+","+e+","+f+","+g+","+h+","+j);         System.out.println("Elapsed: "+((System.currentTimeMillis()-time)/1000.0)+" seconds");     } }```
Output:

Code:

```3,6,1,8,5,4,2,7,9 Elapsed: 0.047 seconds```

what is A, B, C, D...?
If A=3 B=6...
then AB+CD = 99 :| i'm sorry :(
You forgot they are different. But still that's nice programming :)
• Jun 10th 2010, 10:19 AM
FoxEcho
Wow! Thanks a lot!
If I have other puzzles like this (which I'm sure I'll have)
I'll post them here if you don't mind.

Merci,
FE
• Jun 10th 2010, 10:21 AM
Wilmer
Quote:

Originally Posted by FoxEcho
I'm trying to solve this puzzle for a geocaching challenge:

Aren't those competitions, thus illegal for you to get help?
• Jun 10th 2010, 10:25 AM
undefined
Quote:

Originally Posted by hungthinh92
what is A, B, C, D...?
If A=3 B=6...
then AB+CD = 99 :| i'm sorry :(
You forgot they are different. But still that's nice programming :)

Yes A=3, B=6, etc. Figured I could omit that since it's the most natural way to list them out.

AB = 36
CD = 18

36 + 18 = 54, not 99...

Quote:

Originally Posted by Wilmer
Aren't those competitions, thus illegal for you to get help?

That is a good point. I don't know what geocaching is, and thought it's just some puzzle for fun that doesn't really count for anything.
• Jun 10th 2010, 10:29 AM
I'm trying a non-computing approach.

Finding an ordering on them is easier. Reduces amount of possibilities.

Brb not looking at solution
• Jun 10th 2010, 10:32 AM
FoxEcho
Like he says, this is just for fun,