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.
Hi, I have solved the problem but i face a timeout/algorithm complexity issue. I have solved it using a nested forloop. Basically for a^2-b^2 = N where b is the inner square(non tile laminae).In order for the tiles to arrange themselves in such a way where there is always a non tile laminae, b should exist as an integer.
here is the logic:
for m in range(4,t+1,4):
x = (m/4)+1
for i in range(int(x),2,-1):
if(i*i>m and math.sqrt(i*i-m).is_integer()):
c += 1
elif(i*i<=m): break
Can someone suggest how i can improve my code.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #173: Using up to one million tiles how many different "hollow" square laminae can be formed?
You are viewing a single comment's thread. Return to all comments →
Hi, I have solved the problem but i face a timeout/algorithm complexity issue. I have solved it using a nested forloop. Basically for a^2-b^2 = N where b is the inner square(non tile laminae).In order for the tiles to arrange themselves in such a way where there is always a non tile laminae, b should exist as an integer. here is the logic:
for m in range(4,t+1,4):
Can someone suggest how i can improve my code.