N is a ten digit positive integer having the form ABCDEFGHIJ, where each of the letters represent a different digit from 0 to 9.
Find the value of N, given that:
1. Either A = B/3 or A = G + 3.
2. Either B = I - 4 or B = E + 4.
3. Either C = J + 2 or C = F*3.
4. Either D = G*4 or D = E/3.
5. Either E = J - 1 or E = D/4.
6. Either F = B*2 or F = A - 4.
7. Either G = F + 1 or G = I - 3.
8. Either H = A/2 or H = C*3.
9. Either I = H + 3 or I = D/2.
10. Either J = H - 2 or J = C*2.
*** The
or definition is exclusive for each of the ten parts.
Private Sub Form_Load()
ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
s$ = "0123456789": hold$ = s$
Do
a = Val(Mid(s$, 1, 1))
b = Val(Mid(s$, 2, 1))
c = Val(Mid(s$, 3, 1))
d = Val(Mid(s$, 4, 1))
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))
good = 1
If Not ((b = 3 * a) Xor (a = g + 3)) Then good = 0: GoTo bad
If Not ((b = i - 4) Xor (b = e + 4)) Then good = 0: GoTo bad
If Not ((c = j + 2) Xor (c = f * 3)) Then good = 0: GoTo bad
If Not ((d = 4 * g) Xor (e = d * 3)) Then good = 0: GoTo bad
If Not ((e = j - 1) Xor (d = 4 * e)) Then good = 0: GoTo bad
If Not ((f = 2 * b) Xor (f = a - 4)) Then good = 0: GoTo bad
If Not ((g = f + 1) Xor (g = i - 3)) Then good = 0: GoTo bad
If Not ((a = 2 * h) Or (h = c * 3)) Then good = 0: GoTo bad
If Not ((i = 3 + h) Or (d = i * 2)) Then good = 0: GoTo bad
If Not ((j = h - 2) Or (j = c * 2)) Then good = 0: GoTo bad
bad:
If good Then
Text1.Text = Text1.Text & s$ & crlf
DoEvents
End If
permute s$
Loop Until s$ = hold$
Text1.Text = Text1.Text & "done"
End Sub
finds
5038612947
and it works equally well with Or as with Xor.
|
Posted by Charlie
on 2014-06-10 15:18:45 |