Ad
  • Custom User Avatar

    In JS, when you add a boolean to a number, true is converted to 1 and false is converted to 0. Poor readability and too dubious to be used in actual product. You could easily turn it to a ternary for explicity by adding a "... ? 1 : 0" at the end. On another note, using one letter variables is even worse practice elsewhere, although not much of a problem here.

  • Custom User Avatar

    I don't see the point of using non-capturing groups. You might want to extract the date with it.

  • Custom User Avatar

    It needs to enable Node 10 for JS because you cannot use BigInt otherwise which makes it unnecessarily difficult. I can't calculate x * x because it overflows. I am still thinking on how to calculate y at O(n) without x^2.

  • Custom User Avatar

    Such a sweet, well-written solution. Even looking at it makes me feel better (and a bit jealous.)

  • Custom User Avatar

    When you get an error, you don't see the following tests. There are more tests after that. You probably solved this one but it is for others on the website.

  • Custom User Avatar

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

  • Custom User Avatar

    Very interesting, indeed.

  • Custom User Avatar

    SOLVED: Don't modify the 'functions' array. If you pop, push, shift or unshift, it won't work because the tester function also calls the same functions from the same array. The same thing doesn't happen with the first four sample tests because the expected outcomes are hardcoded instead of being evaluated at runtime.

    What he said. Random tests appear to expect the input. I can simply return the input value unchanged and all the random tests are passed but then the first four sample tests are incorrect.

    A couple of examples:

    Log
    function (s){return s.toUpperCase()}
    function (s){return s[0].toUpperCase() + s.substring(1).toLowerCase()}
    function (s){return s.split("")}
    function (l){return l.join("-")}
    function (s){return s[0].toUpperCase() + s.substring(1).toLowerCase()}
    Random test 11 - Expected: '"lmxx9k"', instead got: '"L-m-x-x-9-k"'
    Log
    function (s){return s.toLowerCase()}
    function (s){return s[0].toUpperCase() + s.substring(1).toLowerCase()}
    function (s){return s.toUpperCase()}
    function (s){return s.toUpperCase()}
    function (s){return s[0].toUpperCase() + s.substring(1).toLowerCase()}
    Random test 12 - Expected: '"wxb3wf"', instead got: '"Wxb3wf"'

  • Custom User Avatar

    This question omits the possibility that the domain name may not be the first thing you encounter after a possible "www." or "https?://". For example, a possible domain name could have been https://forum.dingdong.com. I am not sure what kind of a regex could catch it.

  • Custom User Avatar

    There is nothing smart there. It goes through every possible substring just like every other solution does. There is no way around there. It just does it in reverse.

  • Custom User Avatar

    I contest that this is a best practice or clever. Run a timer with this function and compare it to the other solutions here to see how awful it is. There are some that run approximately 15 times faster.

  • Custom User Avatar

    People need to stop using "Best Practices" button as a like button. How the f is this an easy to read and understand solution?

  • Custom User Avatar

    People need to stop using "Best Practices" button as a like button. How the f is this an easy to read and understand solution?