Hacker News new | ask | show | jobs
by allenlavoie 3128 days ago
It's a nice xor swap, but I think you reversed your list twice. And xor swapping with x=y=2 is likely not ideal. Seems like exactly what I'd do in an interview too :p
2 comments

The xor swap failure when working on the same variable has been nicely exploited in the underhanded C contest: http://www.underhanded-c.org/_page_id_16.html

> The XOR-swap trick is an example of coders being too clever for their own good. Here, it gradually poisons the RC4 permutation with zeroes, until eventually the plaintext is just passed along in the clear.

Ha! Those are always good reads. Thanks.
See, I'd need to run and debug it to figure all that out.

But apparently some people can just write it all out on a whiteboard in one go.