3 ms·
> how to find a duplicate in an integer list by using xor I've never heard of that trick and would never have thought of it on my own. It takes a moment's thou
by WalterBright 6y ago
> how to find a duplicate in an integer list by using xor
I've never heard of that trick and would never have thought of it on my own. It takes a moment's thought to see why it works, and I like it.
Bit twiddling is a bit like symbolic integration. There isn't a systematic approach, it's just an accumulation of formulae that people have stumbled upon over time. You can buy books of them. (These days, of course, you just use a program that has them all hardcoded into it.)