Hacker News new | ask | show | jobs
by anonytrary 2650 days ago
Just work out the math for N = 3 and you'll see why your solution is wrong.

X = Mean([a,b,c]) = (a+b+c)/3

Y = YourFunction([a,b,c]) = (((a+b)/2)+c)/2 = (a+b+2c)/4

X does not equal Y. It doesn't matter if the reduce is left or right, btw, it's still wrong.