Ad
  • Custom User Avatar

    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.

  • Default User Avatar

    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 short foreach 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).