Ad
  • Custom User Avatar

    all returns as soon as it finds the first negative. there's no advantage in using any instead of all.

  • Custom User Avatar

    Testing computational complexity is a real pain. We can't really test worst case complexity as it depends on the algorithm used. We could try average complexity, but that needs extensive test with big input (because we want the asymptotic complexity). I think it's impossible to test thoroughly on this platform since tests are limited in time.
    We could possibly test for an upper bound rather than an asymptotic behavior (no more than 4*n access operation for example), this would allow us to test on smaller set of data. However, that requires to monitor access operation, and it's impossible here. Firstly because some languages like JavaScript don't allow to override array access operators for example, but also because the algorithm being tested might as well work on a copy of the input (converting it into another data structure).
    I'd conclude that your initial approach is good enough, as long as it only yields false positives but isn't too restricting to yield false negatives. It's just an incentive to write efficient code :) In the end we're here to train, these are not exams :D

  • Custom User Avatar

    This takes longer than 6 seconds to load, so it was failing for me. I was able to load for k = 400, but I'm concerned that this assertion may cause the tests to become too brittle and may break existing solutions. There's also to guarantee that the assertion will really weed out non O(N) solutions. Testing for time complexity is a real pain. I appreciate the feedback!

  • Custom User Avatar

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

  • Custom User Avatar

    Marking issue as resolved.

  • Custom User Avatar

    Fixed. Here are the changes that I made:

    • Updated description to require solution in O(N) time.
    • Added tests for huge randomly strings for both JavaScript and Python.

    I'd be interested to see if your initial O(N^2) solution still works.

  • Custom User Avatar

    you upvote a beta kata by choosing ready after you have solved it

  • Custom User Avatar

    How do we upvote katas in beta process ? I can't find a place where I can click on the upvote counter to add mine. Thank you for your help

  • Custom User Avatar

    Interesting. I'm going to add some randomized tests tonight. I may need to throw out the O(n) test because I'm not sure if it can be truly tested, but I'll try.

  • Custom User Avatar

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

  • Custom User Avatar

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