Ad
  • Custom User Avatar

    It is not surprising that you are able to sometimes pass and sometimes fail with the same code, because most Codewars kata include random tests that are re-generated every time you try to submit your code. So it can happen that you are "lucky" in some submissions and "unlucky" in other.

    For your buggy solution specifically (although you do not provide it so I cannot see it), it could mean that the Python submission tests are too weak and should be hardened. However, it is not always easy to predict all mistakes people could make, as it is possible to solve the same task with many different algorithms and some solutions have subtle bugs that only happen for rare values.

  • Custom User Avatar

    The issue wasn't just the incorrect sum (which I was aware of), but rather the inconsistent behavior of the assert engine. Despite making no changes to the test values or code, tests would randomly pass or fail. In some instances, even with the correct string, it would throw an error. Paradoxically, the same code with the correct sum would fail, yet running it again without modifications would suddenly pass. It was baffling.

    To resolve this, I reset the code completely, reimplemented the correct solution, and it finally worked consistently.

    This appears to be a platform bug. If you encounter tests arbitrarily passing or failing without code changes, remember that resetting the problem is likely your solution

  • Custom User Avatar

    nitpick: minor typo in the description indivi[DU]al

  • Custom User Avatar

    your algo is wrong

    please re-read the description

  • Custom User Avatar

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