Ad
  • Custom User Avatar

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

  • Custom User Avatar

    This solution has the undesirable side effect of emptying the input array. But hey, it's O(n) time and O(n) space complexity.

  • Custom User Avatar

    (a.pop()|0) + (b.pop()|0) works (same effect as doing ~~)

  • Custom User Avatar

    Fails this test: Test.assertEquals(high('man i need a taxi up to ubud taaxi'), 'taaxi');

  • Custom User Avatar
  • Custom User Avatar

    I am not going to tell, and I leave it for you to figure out. A couple of hints tho:

    • you can print n to console and see what is the last n passed to the function before it hangs. Be careful tho, because with how CW works, not all logs can be visible when timeout occurs, and non-flushed output will be lost and left not visible. You might need to force the flush after every write (but you might not, it depends).
    • you can run your solution locally, on your machine, in a loop, for all numbers from 0 to 100. Or from 0 to 1000, or from 0 to one million, and see if it completes normally or hangs.

    Good luck!

  • Custom User Avatar

    Glad you figured it out. Always make sure to check how many people completed a given kata in your language. If it's at least 3-digit number, it's almost certain that tests are correct (unless it's some obscure edge case). Happy coding ^_^

  • Custom User Avatar

    Programmer error. My debug wasn't outputting the input value of a call that recurses. I can see the problem now, thanks.

  • Custom User Avatar

    My code passes all other tests including the random ones. Just one test it fails on.

    So I had already (before reporting) added a console.log to try and debug so I can see that the input is 43, and yet it fails with

    Log:
    43, 7 (the output from the console.log(original number, returned sum))
    Expected: 9, instead got: 7

    I labelled it an issue because it seemed to be an issue in the tests.

  • Custom User Avatar

    The tests are fine. Notice at the top: JavaScript Completions: 27850

    I don't see a basic test with 43 for JS. Maybe that's result of one of your logs (if you're using recursion, for example)

    Anyway, label issue is for actual problems with kata, not for issues with your code :P For that, use question label first.

    Feel free to reply to get it resolved, but you should start by reading the task again and logging stuff to console to debug your code.

  • Custom User Avatar

    JavaScript: One of the basic tests, 43 asserts the answer should be 9, but the answer should be 7.