Ad
  • Custom User Avatar

    There might be an equation somewhere that you can use to calculate the distance between two points

  • Custom User Avatar

    Not quite sure where to start with this one.

    1. 1.0 strictly equals 1 in JS. That is not a reason this test could be failing.
    2. All numeric literals in JS are instances of Number. There in fact cannot be a difference between a floating-point representation of integers and "actual" integers without using BigInt - they are the same thing.
    3. What is printed is generally irrelevant to passing tests on Codewars.
    4. You can see there are over 1000 successful JS submissions, so it is clearly not true that the last test case will never be achieved.
    console.log(1 === 1.0);
    >> true
    

    Not a kata issue, closing - and please double-check your issues before you raise them :)

  • Custom User Avatar

    In javascript the float "1.0" will be printed as just 1, the last test case never will be achieved

    39 => 3.9

    9 => 0.9

    10 => 1 XXXX

  • Custom User Avatar

    I can't figure out how the distance is being calculated :C Any tips=

  • Default User Avatar

    Thank you so much for your explanation and the function explaining it. I tested it and it worked with my assumptions in the way your functions explained. I shall look more into bitwise operations as well.

  • Custom User Avatar

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

  • Custom User Avatar

    Now I can read it: does nobody notice the medium random tests in JS have a zero more than in Python? Josh even said so!

    Not that it matters though. Node 8.x consistently fails my solution, even with 1e5; Node 14.x consistently passes my solution, even with 1e6.

  • Custom User Avatar

    the Node version is 8.x perhaps 14.x would be faster ? i just enabled it, if you want to try

    For my naive solution, this immediately let me pass ..

  • Custom User Avatar

    You know as well as me how it works: it is a 7 kyu because beta testers ranked it 7 kyu.

    I know. I don't know if they did that before or after the JS translation, and which language version they ranked.

  • Default User Avatar

    i do not think it significantly improved performance either. i tried the solution from the top message above who reports a time out and it is still too slow. but it uses Array.splice() which i reckon is rather expensive because it must shift the array indices to the right of idx

  • Custom User Avatar

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

  • Default User Avatar

    the Node version is 8.x perhaps 14.x would be faster ? i just enabled it, if you want to try

  • Custom User Avatar

    If it's 7kyu, IMO more or less any naive solution should pass, in any language.

    There is not even a good reason for tests with millions of numbers, or numbers of millions. What does that add, to a 7kyu kata ?!?

    Yes, I think this issue is an Issue.

  • Custom User Avatar

    I've just tried to implement my original Python's solution in JS, and it times out. JS is usually much faster than Python, maybe Python list slicing implementation allows a fast execution here. That's beyond me. I don't know what should be done, but it appears that numbers ranges do match between languages and they are not the culprit. I'm not convinced this should be considered an issue, it's hard to find an exact equality between languages (very often Python slowness makes things harder in this language); not all naive solutions fail in JS.

  • Custom User Avatar

    That's what I would call naive, and it definitely times out in JS. Josh reports that the numbers don't match between Python and JS. Possibly someone added a zero somewhere.

  • Loading more items...