+--+--+--+
|2 | 6| 4|
+--+--+--+
|2 | 0| 0|
+--+--+--+
The 2x3 grid given above has an interesting property: If you read horizontally, you get 264 and 200, where 264×200 = 52800. If you read vertically, you get 22, 60 and 40, where 22×60×40 = 52800.
So the horizontal product is the same as the vertical product. Find a 2×4 grid with the same property using 8 different digits.
+--+--+--+--+
| 2 | 7 | 9 | 3 |
+--+--+--+--+
| 1 | 6 | 8 | 0 |
+--+--+--+--+
----------------
for a in '1234567890':
for b in '1234567890':
if a==b:
continue
for c in '1234567890':
if a==c or b==c:
continue
for d in '1234567890':
if a==d or b==d or c==d:
continue
for e in '1234567890':
if a==e or b==e or c==e or d==e:
continue
for f in '1234567890':
if a==f or b==f or c==f or d==f or e==f:
continue
for g in '1234567890':
if a==g or b==g or c==g or d==g or e==g or f==g:
continue
for h in '1234567890':
if a==h or b==h or c==h or d==h or e==h or f==h or g==h:
continue
lhs = int(a+b+c+d)*int(e+f+g+h)
rhs = int(a+e)*int(b+f)*int(c+g)*int(d+h)
if lhs == rhs:
print(a,b,c,d,e,f,g,h)
Program output:
2 7 9 3 1 6 8 0
|
Posted by Larry
on 2023-10-04 08:17:05 |