A Neat Bitwise Trick for Swapping Even and Odd Bits Posted by lawrencewu on Wednesday March 21, 2018 @12:40PM from the dailycodingproblem.com dept. https://www.dailycodingproblem.com/blog/neat-bitwise-trick/ ( 3 comments | on HN )
The table deference will take 1 or 2 operations instead of the AND/SHIFT/PUSH/AND/SHIFT/POP/OR described in the answer.
This trick will work for any number of bits though. You might not want to use 2^64 entries in your table.
And the "trick" given in the answer still depends on a fixed number of input bits, no matter if it's 8, 32, or 10^100.