Well, somehow I managed to remember the site after 2 years of inactivity, and decided to start wasting some homework time here, again.
First off, I decided to find the maximum value of
A by determining when
A²+(
A+
1)² was as close to 100,000 as possible without going over. That gets us a range of
A's to check from
100 to
223.
We check
B over the range
A+1 to
√(100000-A²).
To
check all possible values for A, B, and C, I used the following code in Python.
def five_digit_squares():
cdu=check_digits_used
for val_a in range(100,224):
for val_b in range(val_a+1,int((100000-val_a**2)**.5)):
works=1
val_c=int((val_a**2+val_b**2+0.00000001)**.5)
if val_c**2==(val_a**2+val_b**2) and val_c<=316:
works=cdu(val_a**2)*cdu(val_b**2)*cdu(val_c**2)
if works==1:
used=[]
str_digits=str(val_a**2)+str(val_b**2)+str(val_c**2)
for digit in range(0,15):
if used.count(str_digits[digit])==0:
works=works+1
used=used+[str_digits[digit]]
if works==11:
print(val_a,val_b,val_c)
This ends up getting us a solution of
136 273 305. So,
A is
136,
B is
273,
and
C is
305.
136²=1 8 4 9 6273²=7 4 5 2 9305²=9 3 0 2 5Edited on December 6, 2009, 9:39 pm
|
Posted by Justin
on 2009-12-06 21:34:31 |