Ad
  • Custom User Avatar

    Description should be language-agnostic

  • Custom User Avatar

    Great kata!

  • Custom User Avatar

    Very true, I've computed the expected result beforehand now. Thanks again

  • Custom User Avatar

    Either compute the expected result beforehand, or make a proper 2d array copy, as I can still do this:

    function invertedRanges(a) {
      a.forEach(x => (x[0] = x[1] = -1));
      return [[0, 100]];
    }
    
  • Custom User Avatar

    Thanks for pointing that out. I've made sure to copy the input so it's not passed to both.

  • Custom User Avatar

    Both user's solution and reference solution receive the same array as input, and since the user's solution is called first, it can arbitrarily modify the array without you ever knowing, e.g.:

    function invertedRanges(a) {
      a.length = 0;
      return [[0, 100]];
    }
    
  • Custom User Avatar

    Can you elaborate please? I've unpublished in the meantime

  • Custom User Avatar

    The user can modify the input.

  • Custom User Avatar

    Random tests have been added for both scala and js, closing this issue.

  • Custom User Avatar

    Ive unpublished while I write some random js tests. I didnt read the docs as I was following the on screen guidance and I didnt realise there was other reading required. I didn't see from the guided help that random tests were compulsory.

    I did search to see if I could see this problem already defined. I couldn't, but if it already exists I'm happy to not republish. The idea is a simplified version of something that recently came up for me at work and I thought it was interesting. I'm sorry if it's not creative enough for you

  • Custom User Avatar

    Did you read available documentation on publishing your first kata?

    Having random tests is in there, in bold blinking all-caps ( well, maybe not literally ).

    Also in there is being original. I seem to remember other versions of this problem. I will not be raising the Duplicate issue unless and until I have found an actual duplicate, but the task seems stale.

  • Custom User Avatar

    You should have had random tests when you published. I suggest unpublishing until you have them for all language versions.

    I haven't solved the kata, but if and when I do, not having random tests is an automatic downvote for me. ( And I only know JS, not Scala. )

  • Custom User Avatar

    I've added random tests for the Scala version now, will add some for the JS version and close the issue when done :)

  • Custom User Avatar

    No random tests.

  • Custom User Avatar

    We've got a similar solution ๐Ÿ˜Ž
    Only thing that's different is that I used foldl' instead of foldl because foldl' tends to be faster and less "lazy".