The alphametics
SOME*DAY=VERONAand
SOME*DAY=VIENNAhave unique, albeit distinct solutions.
Which V gets a higher digit?
DefDbl A-Z
Dim crlf$, used(9)
Private Sub Form_Load()
ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
For s = 1 To 9
used(s) = 1
For d = 1 To 9
If used(d) = 0 Then
used(d) = 1
For o = 0 To 9
If used(o) = 0 Then
used(o) = 1
For m = 0 To 9
If used(m) = 0 Then
used(m) = 1
For e = 0 To 9
If used(e) = 0 Then
used(e) = 1
somev = 1000 * s + 100 * o + 10 * m + e
For a = 0 To 9
If used(a) = 0 Then
used(a) = 1
For y = 0 To 9
If used(y) = 0 Then
used(y) = 1
dayv = 100 * d + 10 * a + y
prod = somev * dayv
If prod > 99999 And prod < 999999 Then
p$ = LTrim(Str(prod))
v = Val(Mid(p, 1, 1))
r = Val(Mid(p, 3, 1))
n = Val(Mid(p, 5, 1))
If used(v) = 0 And used(r) = 0 And used(n) = 0 Then
If v <> r And r <> n And v <> n Then
If e = Val(Mid(p, 2, 1)) And o = Val(Mid(p, 4, 1)) And a = Val(Mid(p, 6, 1)) Then
Text1.Text = Text1.Text & somev & Str(dayv) & Str(p) & crlf
End If
End If
End If
i = Val(Mid(p, 2, 1))
n = Val(Mid(p, 4, 1))
If used(v) = 0 And used(i) = 0 And used(n) = 0 Then
If v <> i And i <> n And v <> n Then
If e = Val(Mid(p, 3, 1)) And n = Val(Mid(p, 5, 1)) And a = Val(Mid(p, 6, 1)) Then
Text1.Text = Text1.Text & somev & Str(dayv) & Str(p) & crlf
End If
End If
End If
End If
used(y) = 0
End If
Next
used(a) = 0
End If
Next
used(e) = 0
End If
Next
used(m) = 0
End If
Next
used(o) = 0
End If
Next
used(d) = 0
End If
Next d
used(s) = 0
Next s
Text1.Text = Text1.Text & "done" & crlf
End Sub
finds
1238 605 748990
6837 142 970854
The first is the Vienna version, so Verona has the higher V (= 9).
|
Posted by Charlie
on 2014-11-11 15:44:30 |