Still needing HELPbut should have posted this

  • Thread starter Thread starter strack22
  • Start date Start date
AI Thread Summary
The discussion revolves around a mathematical puzzle involving two equations where unique digits from 1 to 9 are used. The initial equation is structured as ABC + DEF = GHI, and the second as ADG + BEH = CFI. Participants explore solving the puzzle through programming, with one user sharing a code that efficiently finds solutions by checking all unique combinations of digits. The program identifies multiple valid solutions, including pairs like 718 + 236 = 954 and 729 + 135 = 864. The conversation highlights the importance of ensuring digits are unique and discusses the challenges faced when initially overlooking this requirement. Participants also note variations in solutions when including zero or allowing it as a leading digit, which typically isn't standard practice. Overall, the thread emphasizes the effectiveness of computational methods in solving complex digit puzzles.
strack22
Messages
3
Reaction score
0
there is a second part to my original puzzle...sorry

So, IF ABC plus DEF equals GHI THEN,

ADG, plus BEH equals CFI...

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
 
Physics news on Phys.org
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:
718236954     718 + 236 = 954             729 + 135 = 864
729135864     729 + 135 = 864             718 + 236 = 954

and the program:

Code:
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:
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!
 
Alkatran said:
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:
718236954     718 + 236 = 954             729 + 135 = 864
729135864     729 + 135 = 864             718 + 236 = 954

Hm. I wrote a program that found 4 solutions:

Code:
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:
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:
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
 
Interestingly, when I run the program again I get all four answers. I must have missed them somehow.
 
"In 2013, after a series of hospitalizations due to magnets, New Zealand government officials permanently banned the sale of those made from neodymium-iron-boron (NIB)." https://www.sciencealert.com/new-zealand-teen-loses-part-of-his-bowel-after-swallowing-nearly-200-magnets "A 13-year-old boy in New Zealand has had part of his bowel surgically removed after he ingested nearly 200 high-powered magnets. (2025)" OK, this teen was a fool, but it is not always a teen, it is not always...
Thread 'RIP Chen Ning Yang (1922-2025)'
https://en.wikipedia.org/wiki/Yang_Chen-Ning ( photo from http://insti.physics.sunysb.edu/~yang/ ) https://www.nytimes.com/2025/10/18/science/chen-ning-yang-dead.html https://www.bbc.com/news/articles/cdxrzzk02plo https://www.cpr.cuhk.edu.hk/en/press/mourning-professor-yang-chen-ning/ https://www.stonybrook.edu/commcms/physics/about/awards_and_prizes/_nobel_and_breakthrough_prizes/_profiles/yangc https://www.stonybrook.edu/commcms/physics/people/_profiles/yangc...
Back
Top