How many distinct solutions are there to the alphametic
EO*OE=OEOE?
What if Itold you that the two partial products are:
OOO & EEE?
O & E stand for odd and even digits respectively.
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 a = 2 To 8 Step 2
For b = 1 To 9 Step 2
For c = 1 To 9 Step 2
For d = 0 To 8 Step 2
ab = 10 * a + b
cd = 10 * c + d
prod = ab * cd
pr$ = LTrim(Str(prod))
If InStr("13579", Mid(pr$, 1, 1)) > 0 Then
If InStr("02468", Mid(pr$, 2, 1)) > 0 Then
If InStr("13579", Mid(pr$, 3, 1)) > 0 Then
If InStr("02468", Mid(pr$, 4, 1)) > 0 Then
Text1.Text = Text1.Text & ab & Str(cd) & " " & prod
good = 1
pp1$ = LTrim(Str(ab * d))
pp2$ = LTrim(Str(ab * c))
If Len(pp1) = 3 And Len(pp2) = 3 Then
For i = 1 To 3
If InStr("02468", Mid(pp1, i, 1)) > 0 Then Mid(pp1, i, 1) = "e" Else Mid(pp1, i, 1) = "o"
If InStr("02468", Mid(pp2, i, 1)) > 0 Then Mid(pp2, i, 1) = "e" Else Mid(pp2, i, 1) = "o"
Next
If pp1 = "ooo" And pp2 = "eee" Or pp1 = "eee" And pp2 = "ooo" Then
Text1.Text = Text1.Text & " * "
End If
End If
pp1$ = LTrim(Str(cd * b))
pp2$ = LTrim(Str(cd * a))
If Len(pp1) = 3 And Len(pp2) = 3 Then
For i = 1 To 3
If InStr("02468", Mid(pp1, i, 1)) > 0 Then Mid(pp1, i, 1) = "e" Else Mid(pp1, i, 1) = "o"
If InStr("02468", Mid(pp2, i, 1)) > 0 Then Mid(pp2, i, 1) = "e" Else Mid(pp2, i, 1) = "o"
Next
If pp1 = "ooo" And pp2 = "eee" Or pp1 = "eee" And pp2 = "ooo" Then
Text1.Text = Text1.Text & " r "
End If
End If
Text1.Text = Text1.Text & crlf
ct = ct + 1
DoEvents
End If
End If
End If
End If
Next
Next
Next
Next
Text1.Text = Text1.Text & ct & crlf & "done"
End Sub
finds 65 distinct solutions:
EO OE OEOE
21 50 1050
21 52 1092
21 58 1218
21 70 1470
21 78 1638
21 90 1890
23 70 1610
23 72 1656
25 50 1250
25 58 1450
25 74 1850
27 54 1458
27 70 1890
29 50 1450
41 30 1230
41 36 1476
41 74 3034
41 90 3690
41 94 3854
43 30 1290
43 38 1634
43 70 3010
43 72 3096
43 90 3870
47 30 1410
47 36 1692
47 70 3290
47 74 3478
49 30 1470
49 70 3430
61 18 1098
61 30 1830
61 50 3050
61 54 3294
61 56 3416
61 90 5490
61 92 5612
61 96 5856
63 30 1890
63 52 3276
63 58 3654
63 90 5670
65 50 3250
65 78 5070
65 90 5850
67 16 1072
67 54 3618 *
67 76 5092
69 50 3450
81 16 1296
81 18 1458
81 38 3078
81 70 5670
81 72 5832
81 90 7290
81 92 7452
81 94 7614
83 18 1494
83 70 5810
83 90 7470
83 92 7636
85 38 3230
85 90 7650
87 14 1218
87 90 7830
The one marked with an asterisk is the only one that has the two given partial products.
|
Posted by Charlie
on 2014-10-16 15:07:00 |