3 ms·
Just by doing a few examples and thinking through it a little I think there is also another way to do this in binary with bit shifting using the same principles
by johnsonjo 7y ago
Just by doing a few examples and thinking through it a little I think there is also another way to do this in binary with bit shifting using the same principles as the modulo 3 trick. It uses the fact that a bit when it is on modulo three alternates between 1 and 2. Maybe you could then 'unzip' the binary string and then use the string replacement strategy in two alternate ways depending on if it's one of the odd bits or even bits.
EDIT: hmm, unzip is probably the wrong term here.