The unordered set S=(1818, 8811, 1881, 1818) represents 4 distinct decimal numbers: A, B, A+B, A-B.
All "8"s denote the same digit while each "1" stands for a different digit, distinct from all the others .
What digit is not used in S ?
The numbers are
3979 9948 1990 5969
so the missing digit is 2.
DefDbl A-Z
Dim crlf$, dig(9)
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
d$ = "1234567890": h$ = d
Do
c = Val(Right(d, 1))
w = 1000 * Val(Left(d, 1)) + 100 * c + 10 * Val(Mid(d, 2, 1)) + c
x = 1100 * c + 10 * Val(Mid(d, 3, 1)) + Val(Mid(d, 4, 1))
y = 110 * c + 1000 * Val(Mid(d, 5, 1)) + Val(Mid(d, 6, 1))
z = 101 * c + 1000 * Val(Mid(d, 7, 1)) + 10 * Val(Mid(d, 9, 1))
If x + y = z And Abs(x - y) = w Or x + y = w And Abs(x - y) = z Then
Text1.Text = Text1.Text & w & Str(x) & Str(y) & Str(z) & crlf
End If
If x + z = w And Abs(x - z) = y Or x + z = y And Abs(x - z) = w Then
Text1.Text = Text1.Text & w & Str(x) & Str(y) & Str(z) & crlf
End If
If x + w = z And Abs(x - w) = y Or x + w = y And Abs(x - w) = z Then
Text1.Text = Text1.Text & w & Str(x) & Str(y) & Str(z) & crlf
End If
If w + y = z And Abs(w - y) = x Or w + y = x And Abs(w - y) = z Then
Text1.Text = Text1.Text & w & Str(x) & Str(y) & Str(z) & crlf
End If
If w + z = x And Abs(w - z) = y Or w + z = y And Abs(w - z) = x Then
Text1.Text = Text1.Text & w & Str(x) & Str(y) & Str(z) & crlf
End If
If z + y = x And Abs(z - y) = w Or z + y = w And Abs(z - y) = x Then
Text1.Text = Text1.Text & w & Str(x) & Str(y) & Str(z) & crlf
End If
DoEvents
permute d
Loop Until d = h
Text1.Text = Text1.Text & " done"
DoEvents
End Sub
|
Posted by Charlie
on 2019-10-01 15:44:37 |