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.
- Prepare
- Python
- Math
- Triangle Quest 2
- Discussions
Triangle Quest 2
Triangle Quest 2
Sort by
recency
|
1153 Discussions
|
Please Login in order to post a comment
why this code isn't accepted?
print(*[str(i) for i in range(1,i+1)], *[str(i) for i in range(i-1,0,-1)], sep = '')
or this print(*range(1,i+1), *range(i-1,0,-1), sep = '')
in task description nothing said about that returned value should be integer
for i in range(1,int(input())+1): #More than 2 lines will result in 0 score. Do not leave a blank line also print((10**i // 9) ** 2)
for i in range(1, n + 1): print(int("1" * i) ** 2)
why is this showing an error as invalid string literal.
My thought is simple as increasing the number of 1 each time loop increases and then printing the square as this series repeats as a square of increasing 1,11,111,1111
simpler using maths
N=int(input()); [print((10**i //9)**2) for i in range(1,N+1)]
or by strings
N,a,k=int(input()),'',[] ;[k.append(a:=a+f'{i}') or print(a+k[i-2][::-1] if i>1 else i) for i in range(1,N+1)]
math solution