Ad
  • Custom User Avatar

    In theory those solutions should get invalidated when someone next pushes changes to the Python test suite, but those runner jobs do seem to sometimes just vanish into the ether.

  • Custom User Avatar

    For years, the Python version of this kata only has 12 fixed tests and doesn't have any random test.

    Recently, additional random tests were added.

    That's why some less efficient solutions that used to pass will timeout.

  • Default User Avatar

    There's a lot to answer here but, briefly:

    • on old katas, you may be seeing code that dates back almost 10 years; corresponding to different language versions (in Python, many old solution are in Python 2 for example)

    • the performance of the code runner on Codewars can change (but generally the mods/admins will check katas to make sure that they can still be completed)

    • in some cases, users and mods will upgrade tests to katas that were "too simple" (i.e. if they allowed simple brute force solutions to pass), but this will always be done making sure the kata can still be completed within the time limit

    In your case; the code you show above contains a few inefficiencies - now that you have found a working solution, it would be a good learning experience to re-read your old approach and work out why it was so slow (it has to do with the data structure you were using).

  • Default User Avatar

    I haven't been on Codewars for long enough to be 100% sure, but I've read that the performance of the Python code runner has changed over the years.

    You may be right therefore: this kata is almost 10 years old, so some of the solutions may correspond to older versions of Codewars or even Python itself.

  • Custom User Avatar

    Can you provide more information here? The examples and details on the Kata explain from the get-go the types of cases that will appear, as well as the fact that there will be a need to write an efficient algorithm due to the requirement of having to handle lists with 10 million elements.