# Still needing HELPbut should have posted this

1. Sep 10, 2006

### strack22

there is a second part to my original puzzle...sorry

So, IF ABC plus DEF equals GHI THEN,

Please any takers on this...it is driving me CRAZY !!!!

the teasers are listed across if that helps
A B C A D G
+D E F + B E H
_______ ________
G H I C F I

Not sure if you will see it correctly ...sorry

2. Sep 10, 2006

### Alkatran

The usual way to solve these puzzles is to turn your two equations into many. For example, based on the small digits: (C + F) mod 10 = (G + H) mod 10 = I. However, whenever I see these puzzles I always just write a computer program to solve them by doing a case-by-case. Here is the output of the program I wrote (notice how there are TWO answers, but that they are very similar):
Code (Text):

718236954     718 + 236 = 954             729 + 135 = 864
729135864     729 + 135 = 864             718 + 236 = 954

and the program:

Code (Text):

Dim d(1 To 9) As Long

Private Sub Main()
Call testDigit(1) 'start the recursion on the first digit
End Sub
Private Sub testDigit(ByVal index As Long)
Dim a As Long
For a = 1 To 9
If digitsContain(a) = False Then 'make sure the digit is unique
d(index) = a 'try this digit in this position
If index < 9 Then
Call testDigit(index + 1) 'go to next digit if we're not at the last one
ElseIf isValid Then 'if we're at the last digit, check the answer
printDigits
End If
End If
Next a
d(index) = 0 'reset digit
End Sub
Private Function digitsContain(ByVal n As Long) As Boolean
Dim a As Long
'Check if the digit 'n' is already used
For a = 1 To 9
If d(a) = n Then
digitsContain = True
End If
Next a
End Function
Private Function isValid() As Boolean
'make sure the digits match the program
isValid = CBool(CLng(d(1) & d(2) & d(3)) + CLng(d(4) & d(5) & d(6)) = CLng(d(7) & d(8) & d(9)))
isValid = isValid And CBool(CLng(d(1) & d(4) & d(7)) + CLng(d(2) & d(5) & d(8)) = CLng(d(3) & d(6) & d(9)))
End Function
Private Sub printDigits()
Dim a As Long
Dim s As String
For a = LBound(d) To UBound(d)
s = s & d(a)
Next a
Debug.Print s, d(1) & d(2) & d(3) & " + " & d(4) & d(5) & d(6) & " = " & d(7) & d(8) & d(9), d(1) & d(4) & d(7) & " + " & d(2) & d(5) & d(8) & " = " & d(3) & d(6) & d(9)
End Sub

Originally I missed the 'unique 1-9' requirement and was finding hundreds of answers. But when I realized they had to be unique the problem space went from a billion possibilities to 362880 possibilities, so it turned out much better!

Last edited: Sep 10, 2006
3. Sep 11, 2006

### strack22

omg...THANK YOU so much....I was trying to figure it out but just assumed that no number would equal more than 10..I was so focused in that respect, I never entertained any other possibilites...geez...but thank you sooo much!

4. Sep 11, 2006

### davee123

Hm. I wrote a program that found 4 solutions:

Code (Text):

ABCDEFGHI    ABC + DEF = GHI    ADG + BEH = CFI
146583729    146 + 583 = 729    157 + 482 = 639
157482639    157 + 482 = 639    146 + 583 = 729
718236954    718 + 236 = 954    729 + 135 = 864
729135864    729 + 135 = 864    718 + 236 = 954

And a few more if you include 0 (I didn't catch where 0 wasn't a valid option?):

Code (Text):

ABCDEFGHI    ABC + DEF = GHI    ADG + BEH = CFI
326584910    326 + 584 = 910    359 + 281 = 640
348562910    348 + 562 = 910    359 + 461 = 820
359281640    359 + 281 = 640    326 + 584 = 910
359461820    359 + 461 = 820    348 + 562 = 910

And even a few more if you let 0 be a leading digit (which is bad form!)

Code (Text):

ABCDEFGHI    ABC + DEF = GHI    ADG + BEH = CFI
023594617    023 + 594 = 617    056 + 291 = 347
023695718    023 + 695 = 718    067 + 291 = 358
045876921    045 + 876 = 921    089 + 472 = 561
056291347    056 + 291 = 347    023 + 594 = 617
067291358    067 + 291 = 358    023 + 695 = 718
067854921    067 + 854 = 921    089 + 652 = 741
089472561    089 + 472 = 561    045 + 876 = 921
089652741    089 + 652 = 741    067 + 854 = 921

DaveE

5. Sep 11, 2006

### Alkatran

Interestingly, when I run the program again I get all four answers. I must have missed them somehow.