Ad
  • Custom User Avatar

    as a russian, i just noticed how weird the singular and plural cases are for days ect lol

  • Custom User Avatar

    ah thank you, such a simple sounding kata, yet its taking me so long haha

  • Default User Avatar

    Hi; the number of lines of code doesn't say anything about the overall time complexity of an algorithm.

    For example, if I write for i in range(10**9971599599): print i, it will also time out even though it is "only 2 lines".

    In your case, your algorithm is O(n^2) complexity; and the big test you are failing has approximately 8,000,000 elements in it - therefore you algorithm is performing approximately 8000000 ** 2 operations which is very large! You need to find a faster approach (i.e. one that doesn't need to perform so many operations).

  • Custom User Avatar

    i only have 3 lines of code, but it keeps failing at that one big number test due to time out, it did the same when i tried it with one line. (i thought something more compact might help but it didnt) :( idk why this keeps happening???

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    writing this solution felt like cheating for some reason lol

  • Custom User Avatar

    ugh that looks so satisfying, i love to try and make all my code as compact as possible. how did i not think of this?!?