Still a pure function because in order for it to be impure , it would have to access variables OUTSIDE of the function call...this function would always output the exact same thing if given the same input because there is no outside state effecting what happens inside the function...
If truly random testing is impossible ( and I don't think so; you know how arbitrary human behaviour is supposed to be different from truly random behaviour ), you could at least randomize the order of testing.
This solution is not correct.
try this. actual answer should be 6.
console.log(maxSequence([-2, 1, -3, 4, -1, 2, 1, -5, 4]));
Still a pure function because in order for it to be impure , it would have to access variables OUTSIDE of the function call...this function would always output the exact same thing if given the same input because there is no outside state effecting what happens inside the function...
пиздец, я в шоке, как таким умным можно быть-то блять.
Your reducer is not a pure function because references currentSum which life outsize the function.
why not?
Great solution
I don't think you get the key of the puzzle ;-)
needs more random tests, check out my cheat solution passing :)
If truly random testing is impossible ( and I don't think so; you know how arbitrary human behaviour is supposed to be different from truly random behaviour ), you could at least randomize the order of testing.
Otherwise, cheating is just too easy.