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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Calling it a bad method is not correct.
It is a naive method, and not intended to be fast.
It is a useful attempt, because it works - and for CodeWars, we get to see the more advanced answers, and try to understand how they work.
These are often written with functions and methods that newer coders do not know exist, or that are difficult to parse.
And if anyone ever accidentally passes a second argument to
solve
, it'll break ( unless it's exactly the right value for the bug because of==
instead of===
).also can't copy-paste from over there and have to actually type lol
But then you'd have to type all those quotes and commas!!
This is beautiful <3
I like this. That -diff unary operation is such a nice touch.
Can't you make this one for loop, that then checks the 2 condition .
It is since Java 8 (didn't know about it either)
Finding the minimum and maximum element in an array has O(n) time complexity, whereas sorting the input takes O(n log(n)). So yes, it will be noticeably faster for larger arrays.
This is done to rule out e.g. leading 0's.
It's first turned into a number, then into a string and finally compared to the original.
String(Number("01")) is "1", which is not equal to "01".
bad method
Basically, he took advantage of the Javascript runtime used to process and verify the solution, which is NodeJS. And NodeJS has this built-in IP Checker function. So yeah, it's actually cheating xD
Exactly
Loading more items...