Triangle Quest

Sort by

recency

|

1072 Discussions

|

  • + 0 comments

    What math equation will get all 1s? Hint: Division.

  • + 0 comments

    I have done the question and run the test, the output looks exactly the same as the test output, hilighted them both to see if there is invisible characters and copie serched the string on the page and it seems they all match up, but the test results in a failed answer.

    I believe this is bugged, and not the first question i came acros with this problem.

  • + 0 comments

    Simple and easy to understand solution:

    Analysis: The series can be written as:

    1 -> (10 ^ 0) * 1

    22 -> (10 ^ 1 + 10 ^ 0) * 2

    333 -> (10 ^ 2 + 10 ^ 1 + 10 ^ 0) * 3

    4444 -> (10 ^ 3 + 10 ^ 2 + 10 ^ 1 + 10 ^ 0) * 4

    55555 -> (10 ^ 4 + 10 ^ 3 + 10 ^ 2 + 10 ^ 1 + 10 ^ 0) * 5

    .......

    series -> 1 * 10^0 + 1 * 10^1 + 1 * 10^2 + 1 * 10^3 + .... 1 * 10 ^ (i)

    sum of n terms -> 1 * (10 ^ (i) - 1)//(10 - 1) -> (10 ^ i - 1)//9

    gp series: a + ar + ar^2 + ..... + ar^(n-1)

    sum of n terms in gp series -> a(r^n - 1)/(r - 1)

    Code:

    for i in range(1, int(input())): print((i) * (10 ** i - 1)//9)

  • + 0 comments

    for i in range(1, int(input())): print((11111111111111111%pow(10, i))*i)

    I don't think it's the best answer as it relies on the fact that input cannot exceed 9. For this given statement, it works fine

  • + 0 comments

    print(i*(10**i-1)//9)