Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    arrays are lists when the differences are irrelevant such as for this use case.

  • Custom User Avatar

    beacuse two guys confirmed something , Tom said he is first and Peter confirmed that

  • Custom User Avatar

    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.

  • Custom User Avatar

    Anyway, this is not an issue with the kata, but a problem with your code. Please use "question" label next time for similar problems.

  • Custom User Avatar

    Whatever the case, you need to return this string, not print it to console.

  • Custom User Avatar

    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.

  • Custom User Avatar

    Wdym it's not correct? The needle is on index 5. You returned blank string.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Custom User Avatar

    try refreshing the page or relaunching your browser, usually it's a cache issue

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Custom User Avatar

    The Haskell one has a pretty sus test case. Why is there Num instance for String? Just write the quotes already.

  • Loading more items...