Ad
  • Default User Avatar

    still applies...

  • Custom User Avatar

    This issue no longer applies.

  • Custom User Avatar

    Why did you marked this as Spoiler? It's really a nice suggestion.

  • Custom User Avatar

    I don't know without benchmarking, but my bet would be on concat being faster as it uses less resources still creating a new array like JSON.parse does.

  • Default User Avatar

    That is true. But sometimes I squeeze out the very last resource of what Codewars allows me to use to test performance and having to clone a 2+ million array 50 times takes away from the 6 second limit. For katas like this I will remember that in the future. I used JSON.parse(JSON.stringify(arr)) in this case, do you know without having to benchmark it if that is significantly slower than [].concat?

  • Custom User Avatar

    You don't have to necessarily put that into the description.

    Just use something like [].concat(*yourtestarray*) as a parameter for the first function in your test cases, as it basically clones it ;)

  • Default User Avatar

    Note to self for future katas: Add to description that original arrays shouldn't get modified and then add test cases to check that.

    All good now, try and resubmit your solution. Thanks for bringing this to my attention!

  • Custom User Avatar

    I've added this to the description. Thanks!

  • Default User Avatar

    thank you for your feedback. I fixed those issues, The Kata will work better. Please try it again

  • Custom User Avatar

    Specifically, the author of the test used some bit manipulation to round, when he/she should have used Math.floor. The bit stuff only works with 32-bit integers. I myself submitted a solution with the same bug just to get the tests passing.

  • Custom User Avatar

    Thank you. Used it on a project calling modbus commands.

    How did you find the solution with not checking the last 5 bits because of inaccuracy?

  • Default User Avatar

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

  • Custom User Avatar

    Thanks for this! I added it to both versions.

    I tested this example with your code and it doesn't pass the test. I also tested it with my code and it fails at the moment when it's testing the boxes (it does pass the 2 other validattions) - Please give it another try.

  • Custom User Avatar

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

  • Default User Avatar

    I'm glad to hear it!