Skip to content

Instantly share code, notes, and snippets.

@avamsi
Last active December 24, 2015 09:37
Show Gist options
  • Save avamsi/c5a218f9bf9074b1c2fb to your computer and use it in GitHub Desktop.
Save avamsi/c5a218f9bf9074b1c2fb to your computer and use it in GitHub Desktop.
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