Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
It does not work if the random array length is 5. ;)
Do not modify the input array (see comments above).
This comment is hidden because it contains spoiler information about the solution
This is NOT how to do this. But it does randomly pass..... ha
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.
A good lesson learned. Thanks!
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.
PHP Translation Kumited - please accept :D
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).
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?
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.