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.
Clever but doesn't pass n = 70 with node v18.
That was my solution at first.
But got:
expected 3226062132197576 to equal 3226062132197568
on perimeter(70)
Brilliant!
| defaults to the next value if the previous one is falsy, || compares if either comparison is true. 0 | 'String' resolves in String, 1 > 0 || -1 > 3 resolves in true.
niiiice solution!
This is bad in terms of time and performance, because you will have to traverse the array 2 times.
you should update your solution because, it's not valid after some added test cases,
it is called prefix increment
As of January 21, 2025, padStart is experimental. I don't think using it is a good practice. Regarding min/max: a variant with normal conditions (see my solution) would be more readable
Regular expressions
How does this work? Why the gi in the regex? I am just learning regex.
|
is technically the bitwise OR operator, while||
is the logical OR. The first one works with the binary representation of the values being compared (coerced to numbers), while the second one works directly with the values being compared.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR
This comment has been deleted.
Wow. This is one of the few low-level katas where thinking of how to make a one-liner is not so easy.
brilliant solution
thanks for including formula name I collect these lol
Loading more items...