Ad
  • Custom User Avatar

    In fact, I tested the solution on my machine (GCC 5). I modified the decompose() function to print every number it received (before the time-out) so I could pass the same numbers to the local application. With no optimizations I got pretty similar execution time (slightly above 7 seconds), so I don't think CW servers can get too ineffecient in code execution. Perhaps, they just don't perform optimizations upon the compilation to save processing time, that is. With -O1 and above, my solution runs about 5 times faster.

    Anyways, I was able to re-submit my solution several times after the first succesful submission. Maybe you were right and it's the server that really matters here. I just found it to be a interesting coincidence (the fact the local app worked approximately as slowly with no optimizations).

  • Custom User Avatar

    C++.

    This is a really neat Kata, rather simple at first glace ...until you find out your initial straight-forward solution is too slow for the tests and should be drastically optimized. This really makes you think and analyze to cut thousands of redundant iterations your algorithm may perform.

    However, what made me really upset about this Kata is... tests themselves. It took me dozens of "Process timed out" errors to successfully submit the very same solution, which, I believed, simply couldn't be optimized any further. Submit to find out some other solutions weren't optimized at all! There were as straight-forward as my first one.

    Coderwars code runner limits execution of your code to 7 seconds now (I believe, it wasn't the case a while ago, since some of the slowest solutions have passed) and your tests are simply not cut out for this. Even with a better solution, I barely can pass the tests as it runs slightly above the limit. It took me dozens of tries to randomly success when generated numbers weren't as large.