ABC + DEF = GHI
GDA + HEB = IFC
There are two sets of simultaneous solutions for the above 2 alphametics,
one being a 90o rotation of the other.
Find both.
No leading zeroes.
The program below prints GHI first and ABC last so that GDA, etc. read correctly downward.
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
s$ = "1234567890": h$ = s
Do
abc = Val(Mid(s, 1, 3))
def = Val(Mid(s, 4, 3))
ghi = Val(Mid(s, 7, 3))
gda = 100 * Val(Mid(s, 7, 1)) + 10 * Val(Mid(s, 4, 1)) + Val(Mid(s, 1, 1))
heb = 100 * Val(Mid(s, 8, 1)) + 10 * Val(Mid(s, 5, 1)) + Val(Mid(s, 2, 1))
ifc = 100 * Val(Mid(s, 9, 1)) + 10 * Val(Mid(s, 6, 1)) + Val(Mid(s, 3, 1))
If abc + def = ghi Then
If gda + heb = ifc Then
If abc > 100 And def > 100 And gda > 100 And heb > 100 Then
Text1.Text = Text1.Text & ghi & crlf & def & crlf & abc & crlf & crlf
End If
End If
End If
permute s
DoEvents
Loop Until s = h
Text1.Text = Text1.Text & crlf & " done"
End Sub
produces
639
157
482
729
146
583
Annotated:
639 ghi
157 def
482 abc
729 ghi
146 def
583 abc
They do not seem to be rotations of each other, although digits that shared a column now share a row and vice versa.
|
Posted by Charlie
on 2017-08-10 11:16:22 |