Ad
  • Custom User Avatar

    You can break it by setting the input array to have length of 0, and this will pass all the random tests.

    The random tests are broken.

    Example is in my solution.

  • Default User Avatar

    It does not work if the random array length is 5. ;)

    Do not modify the input array (see comments above).

  • Default User Avatar

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

  • Custom User Avatar

    This is NOT how to do this. But it does randomly pass..... ha

  • Custom User Avatar

    I seperated the code to show how the first 4 "basic" pass with a certian math problem and the rest pass with a different math problem.

    The fact that the "expected"(on the left side) all change to 0's and pass seems very wrong and confusing.

    Sounds like I'm having issues because I am editing the array that was passed and not creating a new one.
    Maybe I'll find out why that is some day.

    I took a screenshot. http://prntscr.com/e6e6yb but apparently lightshot isnt working right now.
    If you try my code as it is you can see how the "random" section passes with all 0's with the occasional test failing.
    Initally the first 4 would pass and all the random would be "inverted" still with the same code so i made 2 seperate operations with one only affecting the "basic" ones that only had a few numbers. I only had x-x ==0 to show that that is passing. I understand that that would not invert anything. To invert a number you must simply subtract it from its self 2 times, positive or negative numbers work this way.

  • Custom User Avatar

    A good lesson learned. Thanks!

  • Custom User Avatar

    If there is no mention that an input should be actively modified in the Description then it is naturally assumed that your function should be pure (i.e. should not modify the input passed in) as that is considered best practice.

  • Custom User Avatar

    PHP Translation Kumited - please accept :D

  • Default User Avatar

    I think your code does not work. The array length can be up to 100 in the random tests and if the length is greater than 5, your code calculates x-x (== 0).

  • Custom User Avatar

    When I changed the list that was given as an input it failed the random tests but when I created a new list from the input list it worked. Maybe that deserves a mention?

  • Custom User Avatar

    I believe this is broken in JS. I can pass all the Randoms with values = 0 but fail the basic values. Or I can pass the 4 basic and fail all the Random.