Triangle Quest 2

Sort by

recency

|

1153 Discussions

|

  • + 0 comments

    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

  • + 0 comments

    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)

  • + 0 comments

    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

  • + 0 comments

    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)]

  • + 0 comments

    math solution

    print(round(((-101*10 ** i + 10 ** (2 * i + 1) + 10) / 8100 + 10 ** (i - 2)) * 10))