Ad
  • Custom User Avatar

    Very nice kata, but I felt the same about the optimisation - I've completed it in Python as well btw. The description should make the optimisation demands clear, otherwise I've spent hours with my fully working (logic wise) code that would not be accepted by the server. Ended up mindlesly copying prime algorithms from different sites just to see if they improve the speed.
    Kata solved now, but all the good feeling about getting the logic is lost after all the obscure and undefined loops on making it pass the server 12sec limit. Nothing wrong with optimisation katas, but please, make it clear in the description. Had to rate it a "sad face" purely because of that, very nice kata otherwise.
    Maybe author could relax some of his tests, as big numbers do little to test the logic anyway.

  • Custom User Avatar

    I didn't realize that the print view would expose the test cases. Thanks for that. I opened an issue, but it's to specify that I still think the nominal test cases should complete within a second. https://github.com/Codewars/codewars.com/issues/574
    I still think these heavy-duty test runs are putting unnecessary strain on the server.

  • Custom User Avatar

    To see the input of the hidden tests, print it. Did you report this as a bug?

  • Custom User Avatar

    Half (3.5 seconds) is probably pushing it. It takes very little for the server to drop to half-speed. The problem is that there is no way of telling if it's my code or the server. By the time things recovered, I had already "unlocked solutions" to discover that my code would've been okay.

    It would probably be more polite to the CodeWars limited server resources to shoot for within a second.

    In any case, I agree that it would've been nice to at least see what test cases were attempted when the failure occurred so that I could run them locally on my laptop and get an inkling if the processing time is reasonable.

    Interesting note: Turns out that iterating through a list of previous primes (for k in primes) instead of just doing odd numbers takes a little more time for doing a prime check. Changing that line made the short test finish in about 60ms instead of 100ms, so now it passes in about 3.5 seconds. Even though my old code uses far fewer loops, it apparently takes more time than I expected to start each iteration.

  • Custom User Avatar

    I understand your frustation. Usually I keep the tests to half the time given by CW. It's not the fault of the kata if CW runs sometimes erratically. Nevertheless 209 guys passed the kata with Python so it is easily doable when CW runs correctly. I have myself lots of timing-out. Report it as a bug: https://github.com/Codewars/codewars.com/issues.

  • Custom User Avatar

    Okay, I'm going to call for comments before I rate this kata, but I'm going to start down-rating every kata that continues this trend of "you must find the upmost optimized solution or it's a fail" with the Python branch.

    This Kata is a simple logic problem that was forced to be difficult to "solve" in Python because, let's face it, Python is slower than C. At the time, my solution would run the test in 89 to 120ms, but it fails the 7-second barrier. Granted, I'm not using the "sieve" or "wheel" algorithm to generate the primes (just a basic +2 increment with a modulus to the previous primes), but that shouldn't be neccessary. I don't even get to see what the test cases were, so I have no idea how close I am.

    So, I gave up. I unlocked the solutions. I copy & pasted the top solution:
    ...and it FAILED! Yah, the servers were having a bad day. I tried it later this evening, and this time it passed in 2.5 seconds. It's too late for me because I already unlocked the solutions, but I know better than to blame the servers.

    I don't mind a difficult problem, but CodeWars was never designed for code-profiling and evaluating execution times. The time it takes to run the code can vary depending on the server load. Besides, we should be concentrating on solving the problem, not finding the one optimized solution that gets through the server on a good day.

    I've endured two other Python Katas like this, and I've decided that they just aren't worth it. I prefer the Katas where it is truly a test of logic. Either you solved the problem, or you didn't. The world rarely cares if you found a way to make the code run 3 seconds faster. If you want to play the optimization game, then clearly label it as such, and make sure you put enough margin in so that solutions still pass on bad server day.

    Regardless, this is a bad trend in CodeWars. I'm undecided if I want to recommend this to my sons or not.

  • Custom User Avatar

    The run-time of a solution could be updated when you select "compare with my solution" so that you could at least compare the speed of one solution versus your own. I agree that creating a global score would be challenging. Perhaps they could semi-regularly check run times on the top 10 up-voted solutions.