Ad
  • Custom User Avatar

    The kata version of Python is 2.7 you're calling i to two different things and that's making the tests fail.
    Remember to mark your posts as having spoiler content when they do.

  • Default User Avatar

    In order to properly link your code, you must surround it with three backticks and the language you're using after the first set of ticks like this (I used backslash to escape the ticks, otherwise it starts a code block):
    ```python
    CODE HERE
    ```

    So it's hard to say exactly what you're missing without the indentations (missing some could explain the issues, and could help with reading it so I can see which loops are nested). One thing I can see though is that you're clearing the arrays and integer variables pointlessly in the middle to end of the code. That doesn't acomplish anything since initializing the variables in the first place will already handle clearing them, but when you run the function an additional time the variables don't save from previous iterations. It also looks like you may be initializing variables (particularly j and expsum) at the wrong point in the code, try doing it just after you start the relevant loops so it resets itself on each iteration. Otherwise, expsum will continually get larger from adding on past expsums instead of just comparing the number to it's own expsum. The variable j might be okay, but it's hard to tell without seeing the identation.

  • Custom User Avatar

    You should check your Big O Notation (O) of your algorithm, if it is O(n^2) then your code will got an erro timed out.
    The complex of algorithm should be O(n) or O(nLog(n))

  • Custom User Avatar

    You're not passing all the tests, your code timed out with the longest ones. There are 10 basic tests, 500 random tests and 10 performance tests in Python.