Triangle Quest 2

Sort by

recency

|

1167 Discussions

|

  • + 0 comments

    The logic is: For i=3 the numbers = [1,2,3,2,1] and enumerate([1,2,3,2,1]) = [(0,1), (1,2), (2,3), (3,2), (4,1)]. For each (index, value) : value * 10^(length-1-index) (0,1): 1 * 10^(5-1-0) = 1 * 10^4 = 10000 (1,2): 2 * 10^(5-1-1) = 2 * 10^3 = 2000
    (2,3): 3 * 10^(5-1-2) = 3 * 10^2 = 300 (3,2): 2 * 10^(5-1-3) = 2 * 10^1 = 20 (4,1): 1 * 10^(5-1-4) = 1 * 10^0 = 1 Sum: 10000 + 2000 + 300 + 20 + 1 = 12321 """

  • + 0 comments

    Read input

    n = int(input())

    Apply conditional logic

    if n % 2 != 0: print("Weird") elif 2 <= n <= 5: print("Not Weird") elif 6 <= n <= 20: print("Weird") else: print("Not Weird")

  • + 0 comments

    It's stupid that this platform doesn't accept print(int("1"*i)**2)

  • + 0 comments
    for i in range(1, int(input())+1):
        print(pow((10**i)//9, 2))
    
  • + 0 comments

    New non-mathematical solution in Python using string-like operations and Java-like curly braces.

    I'm biased, but I think this is very hacky.

    import io, sys; print(12345678987654321, file=(b := io.StringIO())); s = b.getvalue()
    {sys.stdout.write(s[:i + 1] + s[17 - i:]) for i in range(int(input()))} #enableJavaCurlyBraces=True