primer+rimer+imer+mer+er+r=malaga
There is only one valid solution for the above alphametic.
Find it.
primer Malaga
652745 709030
652745 709030
Appears twice as the interchange of positions 6 and 10 don't matter as they are not used..
Position 6 is not used as initially a bug was that positions 1-6 were used for primer, 2-6 for rimer, etc.
DefDbl A-Z
Dim crlf$, dr
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr(13) + Chr(10)
s$ = "0123456789": hld$ = s
Do
If InStr(s, "0") > 5 Then
primer = Val(Mid(s, 1, 5) + Mid(s, 2, 1))
rimer = Val(Mid(s, 2, 4) + Mid(s, 2, 1))
imer = Val(Mid(s, 3, 3) + Mid(s, 2, 1))
mer = Val(Mid(s, 4, 2) + Mid(s, 2, 1))
er = Val(Mid(s, 5, 1) + Mid(s, 2, 1))
r = Val(Mid(s, 2, 1))
malaga = Val(Mid(s, 4, 1) + Mid(s, 7, 1) + Mid(s, 8, 1) + Mid(s, 7, 1) + Mid(s, 9, 1) + Mid(s, 7, 1))
If primer + rimer + imer + mer + er + r = malaga Then
Text1.Text = Text1.Text & primer & " " & malaga & crlf
End If
End If
DoEvents
permute s
Loop Until s = hld
Text1.Text = Text1.Text & crlf & " done"
End Sub
|
Posted by Charlie
on 2018-04-19 14:52:49 |