6 4 10 A B CD
5 3 8 E F G
7 2 9 H I J
6 4 10 A B CD
7 2 9 E F G
5 3 8 H I J
7 3 10 A B CD
5 4 9 E F G
6 2 8 H I J
7 3 10 A B CD
6 2 8 E F G
5 4 9 H I J
Of course the second and fourth solutions are trivial variations of the first and third, wher (e, f, g) and (h, i, j) are interchanged.
DefDbl A-Z
Dim crlf$, dr
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr(13) + Chr(10)
s$ = "9876543210": hld$ = s
Do
a = Val(Mid(s, 1, 1))
b = Val(Mid(s, 2, 1))
cd = Val(Mid(s, 3, 2))
e = Val(Mid(s, 5, 1))
f = Val(Mid(s, 6, 1))
g = Val(Mid(s, 7, 1))
h = Val(Mid(s, 8, 1))
i = Val(Mid(s, 9, 1))
j = Val(Mid(s, 10, 1))
If a > b And e > f And h > i Then
If a + b = cd Then
If e + f = g Then
If h + i = j Then
Text1.Text = Text1.Text & Str(a) & Str(b) & Str(cd) & crlf
Text1.Text = Text1.Text & Str(e) & Str(f) & Str(g) & crlf
Text1.Text = Text1.Text & Str(h) & Str(i) & Str(j) & crlf & crlf
End If
End If
End If
End If
DoEvents
permute s
Loop Until s = hld
Text1.Text = Text1.Text & crlf & " done"
End Sub
|
Posted by Charlie
on 2018-04-14 14:04:06 |