The 9-pandigital number N=abcdefghi can be divided into 3 triplets: abc, def, ghi relating 1:2:3.
Find N.
192384576
219438657
267534801
273546819
327654981
but one of the above is wrong. It has a zero instead of a 9. The program only checked for all different digits--not for the presence of all non-zero digits.
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For a = 1 To 3
For b = 1 To 9
If b <> a Then
For c = 1 To 9
If c <> b And c <> a Then
part1 = 100 * a + 10 * b + c
part2 = 2 * part1
part3 = 3 * part1
s$ = LTrim(Str(part1)) + LTrim(Str(part2)) + LTrim(Str(part3))
good = 1
For i = 2 To 9
If InStr(s, Mid(s, i, 1)) <> i Then good = 0: Exit For
Next
If good And Len(s) = 9 Then Text1.Text = Text1.Text & s & crlf
End If
Next
End If
Next
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Edited on December 31, 2017, 8:00 am
|
Posted by Charlie
on 2017-12-30 15:37:48 |