You are viewing a single comment's thread. Return to all comments →
My first solution was
print("".join(["".join([str(x) for x in range(1,i)]),str(i),"".join([str(y) for y in range(i-1,0,-1)])]))
After, I was hit with the hidden constraint cant use str(). So I went with
print(sum([x * 10**((1 + (i - 1)*2)-x) + x * 10**(x-1) for x in range(1,i)]) + i * 10**(i-1))
And that returned “you can only use one for loop” …. 😡 But the posted solution
print((10 ** i // 9) ** 2)
Is really elegant so I’m glad to have come to this discussion page.
Seems like cookies are disabled on this browser, please enable them to open this website
Triangle Quest 2
You are viewing a single comment's thread. Return to all comments →
My first solution was
After, I was hit with the hidden constraint cant use str(). So I went with
And that returned “you can only use one for loop” …. 😡 But the posted solution
Is really elegant so I’m glad to have come to this discussion page.