Ad
  • Custom User Avatar
  • Default User Avatar

    How the heck did I forget to add that to the description? Good catch!

  • Default User Avatar

    It's probably an infinite loop.

  • Default User Avatar

    Nope, the test cases do not remotely test performance. Keep in mind there are server timeouts (which means that your code never got to run), vs code timeouts (which means your code took too long to run).

  • Default User Avatar

    You shouldn't need bounds if the function is monotonic.

  • Custom User Avatar

    Interesting. Apparently the JavaScript and Python test frameworks are a bit inconsistent. Fixed now.

  • Custom User Avatar

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

  • Custom User Avatar

    That is certainly the primary conceptual hurdle I'm throwing at people attempting the kata. I don't want to give up the ghost immediately, but I would certainly entertain ideas about how to hint in the right direction without removing the opportunity for the person trying to kata to discover the trick on their own.

    Alternatively, it might just need to have an elevated rank.

  • Default User Avatar

    Oops. Sorry, right. Fixed that. I thought that publishing the kata would check that automatically, but on second thought I understand that it doesn't.

  • Default User Avatar

    Hi Strikeskids, I marked your comment spoiler since it contains a link to your solution.

    The reason it's timing out is this line in your parser:

      var pop = this.pop = this.pop || function() {
    

    The function uses local variables that are different each time pass1 runs, but the function is cached the first time it runs and uses those original local variable values every time. In the test cases, only one compiler instance is created and it is reused for each test, so the compiler instance actually needs to be stateless. Don't cache the pop function and your code works great.

  • Custom User Avatar

    I'm not sure what to tell you. There aren't very many test cases. That one is the last one. Are you timing out while compiling it or while evaluating it? You're sure that you can compile and simulate that function (because a number of times that I've thought things were timing out on me unfairly, I found an edge-case infinite loop or stack overflow in my code)? I know you say it works in your chrome devtools, but does it work if you make your own test here on Codewars? There are some differences in Javascript implementations.

  • Custom User Avatar

    I wonder, that you're the first one after 3 months, who mentions this. But this is fixed now. Thanks for letting me know.

  • Custom User Avatar

    Which test grouping is this? Was it my test code calling your method or was it being called from an around method? or a before method? Specifically, how is it that it got the 'Mammal' discriminator right but no arguments?

  • Custom User Avatar

    If you define two primary methods with the exact same discriminator, the second replaces the first.

    I'm not sure what you mean about "calls the method is being called with no arguments". All of the tests call your method with arguments, but "callNextMethod" is always called with arguments, too.

  • Custom User Avatar

    Thanks for the feedback! Yes, the second test case was meant to make it clear that spaces /are/ significant in the needle. I added a sentence in the description to clarify further.

    Also fixed the missing semicolons and parenthesis, my bad for not triple-checking. If you could check that everything's okay now it would be much appreciated!