• Custom User Avatar

    Nope. For loops are faster and this has to do with how these two constructs have been implemented in Python and to what extent they rely on C
    Also, solving this kata with a for loop should work perfectly fine.

  • Custom User Avatar

    wait while loops are faster than for loops?

  • Custom User Avatar

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

  • Custom User Avatar

    Not actually kata suggestion, closing.
    Regarding your points, there is no reason not to use for loops, most of the solutions use it.
    Just a fun fact: in python for loops are actually faster than while loops :p

  • Custom User Avatar

    Well, as a newbie who spent seven hours on this problem and later found it out, here are some tips for those who pass their basic tests, but fail in attempt (Execution Timed Out: 12000/16000 MS).

    1. Don't use for loops. Isn't there another way?
    2. Don't copy code. Those code don't work. Especially from GeeksforGeeks.
    3. ONLY USE WHILE LOOP/S AND IF STATEMENTS.

    Good Luck. Even if you copy the right code, please understand the computational logic behind it. Thanks.