Skip to content

Instantly share code, notes, and snippets.

@vigneshsarma
Created September 19, 2011 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vigneshsarma/1226711 to your computer and use it in GitHub Desktop.
Save vigneshsarma/1226711 to your computer and use it in GitHub Desktop.
Double Squre
import math
def isSuperSqure(n):
hlf=int(math.sqrt(n))
start=0
count=0
while(hlf>=start):
if((start+hlf)<=n):
no=(start**2)+(hlf**2)
if(no>n):
hlf-=1
elif(no
start+=1
else:
count+=1
print hlf,start,count
hlf-=1
start+=1
return count
if __name__ == "__main__":
f=open("double_squares.txt",'r')
limit=int(f.readline())
fr=open("out1.txt",'w')
while(limit>0):
n=int(f.readline())
limit-=1
fr.write(str(isSuperSqure(n))+'\n')
fr.close()
f.close()
@vigneshsarma
Copy link
Author

Facebook Hackers-cup Double square solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment