count=0 target=5 for x1 in range(target+1): print(x1) for y1 in range(target+1): for x2 in range(target+1): for y2 in range(target+1): a=x1*x1+y1*y1 b=x2*x2+y2*y2 c=abs(x1-x2)**2+abs(y1-y2)**2 if a*b*c==0: continue if a+b==c: count+=1 continue if a+c==b: count+=1 continue if b+c==a: count+=1 print(count/2)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question