Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
I don't see the point of using non-capturing groups. You might want to extract the date with it.
You don't have to calculate "x * x" and there is no need for BigInt.
235 guys passed the JS translation without BigInt. Try to use the Hint.
Can't you use a library?
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.
Such a sweet, well-written solution. Even looking at it makes me feel better (and a bit jealous.)
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.
There are more tests, that only means you've passed all tests until the timeout happened.
I have passed all test
example tests
Completed in 8ms
tests with negative values
Completed in 7ms
FIB ONE MILLION
Test Passed
Completed in 927ms
But there is still a tip 'Execution Timed Out (12000 ms)'
This comment is hidden because it contains spoiler information about the solution
Very interesting, indeed.
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"'
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.
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.
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.
Loading more items...