-
-
Save avamsi/c5a218f9bf9074b1c2fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from itertools import combinations | |
l = defaultdict(list) | |
for i, j in combinations(xrange(1, 10**3), 2): | |
k = i*i + j*j | |
l[k].append((i, j)) | |
if len(l[k]) > 2: | |
# if k is a perfect square -- approximation | |
if int(k**.5)**2 == k: | |
print int(k**.5) | |
print l[k] | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment