Allowing duplicates, as in simultatneous equations, would allow multiple solutions. Since this is an alphametic, duplicates can't be allowed. But when that restriction was added, there were no solutions found.
But then I thought: what if the restriction against value zero did not apply to the letter O. That leads to a unique solution:
Z E R O N T W H F U I V S X G L
-6-1 7 0 2 9-7-11-4 1 6 4 3-3 5 8
-6-1 7 0 0
0 2-1 1
9-7 0 2
9-11 7-1-1 3
-4 0 1 7 4
-4 6 4-1 5
3 6-3 6
3-1 4-1 2 7
-1 6 5-11 9 8
2 6 2-1 9
9-1 2 10
-1 8-1 4-1 2 11
9-7-1 8 4-1 12
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
maxallow = 11
For w = -maxallow To maxallow Step 2
o = (-7 - w) / 2
If Abs(o) <= maxallow Then
t = o + 9 'two
If t <= maxallow And t <> 0 Then
' Text1.Text = "T W O = " & Str(t) & Str(w) & Str(o) & crlf
For e = -maxallow To maxallow
If e <> 0 Then 'ten
n = 10 - t - e
If Abs(n) <= maxallow And n <> 0 Then
i = 9 - 2 * n - e 'nine
If Abs(i) <= maxallow And i <> 0 Then
For s = -maxallow To maxallow ' seven
If s <> 0 Then
v = 7 - 2 * e - n - s
If Abs(v) <= maxallow And v <> 0 Then
l = 12 - 2 * e - v - t - w 'twelve
If Abs(l) <= maxallow And l <> 0 Then
For z = -maxallow To maxallow
If z <> 0 Then
r = -z - e - o 'zero
If Abs(r) <= maxallow And r <> 0 Then
For f = -maxallow To maxallow
If f <> 0 Then
u = 4 - o - f - r 'four
If Abs(u) <= maxallow And u <> 0 Then
h = 3 - t - r - 2 * e 'three
If Abs(h) <= maxallow And h <> 0 Then
x = 6 - s - i 'six
If Abs(x) <= maxallow And x <> 0 Then
g = 8 - e - i - h - t 'eight
If Abs(g) <= maxallow And g <> 0 Then
If o + n + e = 1 Then
If e + l + e + v + e + n = 11 Then
If f + i + v + e = 5 Then
If z <> e And z <> r And z <> o And z <> n And z <> t And z <> w And z <> h And z <> f And z <> u And z <> i And z <> v And z <> s And z <> x And z <> x And z <> l Then
If e <> r And e <> o And e <> n And e <> t And e <> w And e <> h And e <> f And e <> u And e <> i And e <> v And e <> s And e <> x And e <> x And e <> l Then
If r <> o And r <> n And r <> t And r <> w And r <> h And r <> f And r <> u And r <> i And r <> v And r <> s And r <> x And r <> x And r <> l Then
If o <> n And o <> t And o <> w And o <> h And o <> f And o <> u And o <> i And o <> v And o <> s And o <> x And o <> x And o <> l Then
If n <> t And n <> w And n <> h And n <> f And n <> u And n <> i And n <> v And n <> s And n <> x And n <> x And n <> l Then
If t <> w And t <> h And t <> f And t <> u And t <> i And t <> v And t <> s And t <> x And t <> x And t <> l Then
If w <> h And w <> f And w <> u And w <> i And w <> v And w <> s And w <> x And w <> x And w <> l Then
If h <> f And h <> u And h <> i And h <> v And h <> s And h <> x And h <> x And h <> l Then
If f <> u And f <> i And f <> v And f <> s And f <> x And f <> x And f <> l Then
If u <> i And u <> v And u <> s And u <> x And u <> x And u <> l Then
If i <> v And i <> s And i <> x And i <> x And i <> l Then
If v <> s And v <> x And v <> x And v <> l Then
If s <> x And s <> x And s <> l Then
If g <> z And g <> e And g <> r And g <> o And g <> n And g <> t And g <> w And g <> h And g <> f And g <> u And g <> i And g <> v And g <> s And g <> x And g <> x And g <> l Then
If x <> l Then
Text1.Text = Text1.Text & Str(z) & Str(e) & Str(r) & Str(o) & Str(n) & Str(t) & Str(w) & Str(h) & Str(f) & Str(u) & Str(i) & Str(v) & Str(s) & Str(x) & Str(g) & Str(l) & crlf
Text1.Text = Text1.Text & Str(z) & Str(e) & Str(r) & Str(o)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & z + e + r + o & crlf
Text1.Text = Text1.Text & Str(o) & Str(n) & Str(e)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & o + n + e & crlf
Text1.Text = Text1.Text & Str(t) & Str(w) & Str(o)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & t + w + o & crlf
Text1.Text = Text1.Text & Str(t) & Str(h) & Str(r) & Str(e) & Str(e)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & t + h + r + e + e & crlf
Text1.Text = Text1.Text & Str(f) & Str(o) & Str(u) & Str(r)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & f + o + u + r & crlf
Text1.Text = Text1.Text & Str(f) & Str(i) & Str(v) & Str(e)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & f + i + v + e & crlf
Text1.Text = Text1.Text & Str(s) & Str(i) & Str(x)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & s + i + x & crlf
Text1.Text = Text1.Text & Str(s) & Str(e) & Str(v) & Str(e) & Str(n)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & s + e + v + e + n & crlf
Text1.Text = Text1.Text & Str(e) & Str(i) & Str(g) & Str(h) & Str(t)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & e + i + g + h + t & crlf
Text1.Text = Text1.Text & Str(n) & Str(i) & Str(n) & Str(e)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & n + i + n + e & crlf
Text1.Text = Text1.Text & Str(t) & Str(e) & Str(n)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & t + e + n & crlf
Text1.Text = Text1.Text & Str(e) & Str(l) & Str(e) & Str(v) & Str(e) & Str(n)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & e + l + e + v + e + n & crlf
Text1.Text = Text1.Text & Str(t) & Str(w) & Str(e) & Str(l) & Str(v) & Str(e)
Text1.Text = Text1.Text & " "
Text1.Text = Text1.Text & t + w + e + l + v + e & crlf & crlf
DoEvents
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If 'eleven
End If 'one
End If
End If
End If
End If
End If
Next
End If
End If
Next
End If
End If
End If
Next
End If
End If
End If
Next
End If
End If
Next w
Text1.Text = Text1.Text & crlf & ways & " done"
End Sub
Edited on April 7, 2017, 3:53 pm
|
Posted by Charlie
on 2017-04-07 12:26:51 |