Ad
  • Custom User Avatar

    Generally if you run into issues like that it means it's not about "optimizing" your solution but actually starting from scratch and finding a different approach that works. The correct solution to this kata solves it in a fraction of a second. Basically you need to rethink your approach. I can't say more or it would be a spoiler.

  • Custom User Avatar

    Quite often with the harder katas it's not really matter of "optimization" as such (making your algorithm run faster), but instead of finding a completely different approach that is faster.

    The advice above is solid. If you are new to coding you probably shouldn't be doing 4 kyu katas. Start at easier ones and then climb from there.

  • Custom User Avatar

    So I was testing why my solution was timing out (can't honestly imagine how to make it faster) and I made it return just 0 and one of the advanced cases passed.

    Is there really a case that requires 0 (wouldn't really make sense, per the description there is no way to make a case where 0 is correct result) or is this just some timer case that checks if you fit in the 1 second?

  • Custom User Avatar

    You have the code misaligned

    >987v>.v
    v456<  :
    >321 ^ _@
    

    Try looking at it again like this. I don't think I can explain much more without it counting as a spoiler. (remember ^ is "start going up" not "go up one space")