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.
surely let rather than var
bigres should really be typed since it's typescript, but this is better than the efforts that solve it in JavaScript alone.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I like the decomposition here, both the regex definition and the comparison order could be different in the future, this is maintainable code. Very clear. I think shows that just because we can solve a problem in one line, does not mean that we should solve a problem in one line. Voting as best practice.
This comment is hidden because it contains spoiler information about the solution
There is no need to assign P0 but doing so avoids argument mutation. It's good defensive programming since JavaScript is fling those function parameters about by reference.
argument mutation of p0 should be avoided, we can't say if that will not affect the behaviour of p0 outside the function. The test cases state p0 as a number, however it could be supplied as a variable. For the sake of a single extra let statement, it's worth the defencive effort.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I fear a lot of string concatenation going on under the hood. Would be intresting to see if the compiler was inclined to use stringbuilder in processing this. Beautifully succinct code.
Succinct. Kodos.