-
Hello everyone, I am just curious what will happen if somebody creates a Kata with a bad algorithm. Let's say, for example, his algorithm's time complexity is O(N^3), and he also creates a big number of test cases. Will my solution be affected by his ? Explanation: So my question is, will Codewars throw a Timeout Exception or not ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
If somebody creates a kata with a hugely inefficient reference solution, it will fail to publish. Publication requires passing your own tests with your example solution. |
Beta Was this translation helpful? Give feedback.
-
In general: yes, if your solution is performant, but reference solution is bad, then tests will time out and you will not pass. Such kata did happen, and probably some of such kata still linger somewhere in the library. But on the other hand, I don't think that currently kata like this are a significant problem. Some details: When a user attempts a kata, on Codewars server a short-living Docker container is spun up and tests defined by kata author are run. It's not really relevant for the test runner what tests are exactly. They can be anything what kata author comes up with. It's not relevant for the runner if tests use a reference solution, and how fast they are. All what is important is how long does a full test run take. After 12 seconds, or 16 seconds (depending on language), the Docked container is forcefully stopped (if it's still running), and timeout is presented to users. It does not matter what took so long, and runner does not have a chance of knowing it. If tests have been started and were running longer than 12 (or 16) seconds, they get killed, and user submission is decided to me unsuccessful. How user solution, tests, and reference solution work together is determined by kata author. Author decides how many tests are there, if a reference solution is used, and how a user solution is invoked. Some kata do not use reference solution at all (what I strongly advocate for whenever feasible), so it does not waste time quota. But still, there is time spent on setting up the testing framework, generation of inputs, etc. If tests happen to use a reference solution and it turns out to be bad, it's usually not bad enough to reject valid solutions. In the worst case, it would take around half of the available time, because every time when a kata is published, full tests are run just like author would run tests on their own solution, and the authors solution and reference solution used by tests usually tend to be similar - that's why if both were bad, kata could not be published. General recommendation for authors is also to create tests in a way they don't take too much time, except for some demanding performance kata. The situation you describe can happen in following situations:
If you think that you have a good solution but tests are written in a bad way and prevent you from passing, you can always ask a question in kata discourse and someone will investigate. But I would expect this to be related rather to a user solution being not fast enough. |
Beta Was this translation helpful? Give feedback.
In general: yes, if your solution is performant, but reference solution is bad, then tests will time out and you will not pass. Such kata did happen, and probably some of such kata still linger somewhere in the library. But on the other hand, I don't think that currently kata like this are a significant problem.
Some details:
When a user attempts a kata, on Codewars server a short-living Docker container is spun up and tests defined by kata author are run. It's not really relevant for the test runner what tests are exactly. They can be anything what kata author comes up with. It's not relevant for the runner if tests use a reference solution, and how fast they are. All what is important i…