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.
uh, clearly you know about how haskell works, which is good, but you've made weird assumptions about what JS does. Of course it depends between which engine we're on, but since nodejs powers most of the web (as well as is what codewars uses), new arrays are only allocated as needed if the engine decides it can't butterfly the previous array for the correct shallow references that don't get dirty (which is extremely easy to do when it receives the Boolean function, which is pure and doesn't pollute elements being passed through). What actually ends up happening is that most of javascript, unlike java, isn't executed on pure logic that is defined by its exact behaviour and has faster implementations compiled JIT (just in time) on the runtime so that it looks like new arrays need to be properly created where as in reality (happening behind the curtains) it's just the same heap being frankensteined into an efficient array-like item until the array prototype is used and forces the array to actually be constructed.
It has different performance characteristics. This solution means that you allocate a whole new array just so you can find its length.
In Haskell, it's not a problem because list nodes are only created as needed. There is also short cut optimization to make sure that a solution like this will be efficient.
arrays are lists when the differences are irrelevant such as for this use case.
beacuse two guys confirmed something , Tom said he is first and Peter confirmed that
I wish that the input gets simplified, so we get into the core of the problem, which is SAT, instead of also doing parsing too.
Anyway, this is not an issue with the kata, but a problem with your code. Please use "question" label next time for similar problems.
Whatever the case, you need to return this string, not print it to console.
That was a mistake, as I thought we were supposed to put the actual position (index+1), and not the actual index. Secondly, I didn't return a blank string. The code works when it is outside kata, but here, it doesn't.
Wdym it's not correct? The needle is on index 5. You returned blank string.
This comment is hidden because it contains spoiler information about the solution
Thanks
try refreshing the page or relaunching your browser, usually it's a cache issue
This comment is hidden because it contains spoiler information about the solution
Unlike others, I feel iffy about this one. This looks like someone adopted Haskell's solution on an imperative programming language, despite Javascript uses arrays and not list.
The Haskell one has a pretty sus test case. Why is there
Num
instance forString
? Just write the quotes already.Loading more items...