I'm really stuck with it.
I have an array of 9 ints (9 bits each). One, and only one, of these will always include 1 or 2 bits that the other variables don't have set. I need to achieve the following:
1. What is the index of the variable having these non-repeating bits?
2. What is the number formed by these bits?
For example, let's say I have an array with 3 ints (the rest of the elements are all 0):
010 000 110 at index 2
101 000 100 at index 4
010 000 010 at index 6
In the int at index 4 I have that bits 1 and 3 are set only in this variable.
So, I need to perform an operation to let me know that it's the variable at index 4 and the number is 101000000.
It may sound like a homework, but it's really not.
I tried many bitwise operations and combinations of them, but I really can't get the result.