Sort 41 Discussions, By:
Please Login in order to post a comment
I submitted my code knowing that it would time out. Besides throwing zeroes in between the given digits and starting at the ceiling of the square root of that number, I have no idea how to cut the problem down. My code is good up to 10 given digits but it will time out with most cases above that. Any hints as to how you can break the problem down further?
Edit: You can also disregard roots based on the last digit of the given digits. For example, last digit being 1 can only come from 1 or 9, last digit 4 can only come from 8 or 2.
Finally did it. Wow.
That was a super fun (!!) challenge, although a tough one to crack. I felt you really had to get a very good understanding of what happens when squaring numbers, much more than I was expecting from a challenge that was labeled as easy. Maybe this is more of a medium-difficulty challenge? At least for the cases where n is large and you need to explore the space of potential solutions very economically.
I am confused a bit, if the input is
4 3 2 0 1 2 4
What could be the answer? as 2153662 and 2222222 both satisfies the list(or array)...
Passed only 16 cases...Time limit exceeded :/
and it is marked as "Easy" ಥ_ಥ
n = int(input())
fuc = 0
s = list(map(int, input().split()))
flag = 0
res = *(2*n-1)
for i in range(0, 2 * n, 2):
res[i] = s[flag]
flag = flag+1
for i in itertools.count(start=10):
fuc = (i*i)
square = list(map(int, str(fuc)))
if (res[::2] == square[::2]):
for q2 in q1:
for i in range((10(l-1)),(10l)):
for j in range(0,(len(sq1)),2):
if s == x:
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.