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.
It was my mistake, I did not consider cleaning the vars before sending the return, and being global they also kept the values of the previous tests.
There might be something wrong with the random tests in php.
I pass all tests except random, where I get a timeout (over 12000 ms), using my code elsewhere (online php sandbox) on a random array with 95 peaks, looped 100 times, results in: "Total execution time in seconds: 0.085011005401611". I have a
for
loop which contains two very shortforeach
loops for the before and after arrays. Both have breaks and the second does not get used if the first fails. There doesn't seem to be anything to optimise out.Logging to STDOUT, it seems that the random test fails at 293 arrays being generated, but without any of them actually passing through the function (I get 293 '1's and no arrays using
fwrite(STDOUT, print_r($arr));
before my timeout, while passed tests give me one '1' per array, then the actual arrays are printed, as expected).