A six digit perfect square is represented as
AABCAB where the same letter represents the same digit, but a different letter represents a different digit.
It is also known that both these relationships are simultaneously satisfied:
- The numbers represented by each of AAB and CAB is a perfect square.
- The numbers represented by each of AB and ABC is a perfect square.
Determine the digits represented by
A,
B, and
C.
Note: Computer program solutions are welcome, but a semi-analytic(calculator+ p&p) method is preferred.
Given that AB is in {16,25,36,49,64,81},
ABC is limited to {169, 256, 361}
So A is in {1,2,3}
B is in {5,6}
C is in {1,6,9}
AAB candidates are only 115,116,225,226,335,336 of which only 225 is a square:
A = 2
B = 5
CAB is x25 which can only be 225 or 625, but one of these is already taken.
CAB = 625
C = 6
AABCAB = 225625 = 475^2
After the analytic solution, I did a programmatic solution. While I didn't strictly time each one, my impression is that the analytic one took about twice as long as did writing the program.
"""
sq = []
for i in range(1,1000):
sq.append(i*i)
for a in range(10):
for b in range(10):
if 10*a+b not in sq:
continue
for c in range(10):
if 110*a+b not in sq:
continue
if 100*a+10*b+c not in sq:
continue
if 100*c+10*a+b not in sq:
continue
print(a,a,b,c,a,b)
|
Posted by Larry
on 2023-07-06 06:19:29 |