We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #206: Concealed Square
Project Euler #206: Concealed Square
Sort by
recency
|
42 Discussions
|
Please Login in order to post a comment
Yeah can't get past the 16th case (python3) :(
Passed only 16 cases...Time limit exceeded :/
and it is marked as "Easy" ಥ_ಥ
n=int(input()) q=input() q1=q.split(" ") x="" for q2 in q1: x=x+q2 a1=list(x) s="" l=len(a1) for i in range((10(l-1)),(10l)): sq=1 s="" sq1=[] sq=i*i sq1=list(str(sq)) for j in range(0,(len(sq1)),2): s=s+sq1[j] if s == x: print(i) break**
My solution passed 16 test cases only. Rest all the cases aborted due to timeout. Any suggestions to reduce calculation time. My code is in python.
Enter your code here. Read input from STDIN. Print output to STDOUT
n=int(input()) p=str(input()) lst=p.split() num=('').join(p.split()) d=lst[0] e=lst[0] for l in lst[1:]: d+='0'+l e+='9'+l a=int(d)**0.5 b=int(e)**0.5 for z in range(int(a),int(b)+1): k=(z**2) k=str(k) if k[::2]==num: print(z) break break
can anyone tell me how to reduce the looping to generate the expected square root. for me only 17 test cases are passed