We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I'm thinking that the reason we can be assured there's a combination of bits after the first 1 in the xor result is not because "we can create every possible combination within", but for some other reason.
Between 127 and 128 there are only two possible combinations: 128 xor 127, 128 xor 128. Two combinations doesn't assure us that out of a 6 or 7 digit binary value we will hit every bit pattern. The actual two combinations happen to be 1111111 and 0000000, one of which is all bits set, which is what we need to be assured. But I think it's for some other property of the two binary numbers than the distance between them equals the number of possibilities.
I guess it's just because a binary number xor'd with {itself minus one} is always all bits on?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximizing XOR
You are viewing a single comment's thread. Return to all comments →
Something keeps confusing me.
I'm thinking that the reason we can be assured there's a combination of bits after the first 1 in the xor result is not because "we can create every possible combination within", but for some other reason.
Between 127 and 128 there are only two possible combinations: 128 xor 127, 128 xor 128. Two combinations doesn't assure us that out of a 6 or 7 digit binary value we will hit every bit pattern. The actual two combinations happen to be 1111111 and 0000000, one of which is all bits set, which is what we need to be assured. But I think it's for some other property of the two binary numbers than the distance between them equals the number of possibilities.
I guess it's just because a binary number xor'd with {itself minus one} is always all bits on?