Hacker News new | ask | show | jobs
by rglullis 5530 days ago
Since you didn't put SPOILER ALERT, I guess it's okay to say that I was going for a similar approach, except that I was going to use sum of elements and the XOR of all elements. I guess the only advantage is that computing the XOR should be faster/smaller space than summing squares.
1 comments

Your solution won't work because you can't solve for a and b if you are given (a xor b) and (a - b), consider an extra 3 and missing 2 will give 1 for both values, as will extra 5 and missing 4.
Shit, you are right. I was trying to avoid being a victim of nerd sniping on this one, failed at that.