3-Bit Sensors
A remote weather station uses two redundant 3-bit sensors to measure atmospheric pressure. Both sensors transmit their readings to a central processor, but bandwidth is limited. The engineers know the sensors are well-calibrated—their readings can differ by at most one bit.
The station’s designer claims that sensor B only needs to send 2 bits instead of 3, and the processor can still reconstruct B’s full reading. Sensor B knows that sensor A has already sent its 3-bit sequence to the processor, but B doesn’t know what that sequence was. How can this work?
Solution
Answer: B sends two bits: xb=b1⊕b2 and yb=b2⊕b3, where ⊕ denotes XOR.
Let’s say A’s reading is (a1,a2,a3) and B’s reading is (b1,b2,b3). B computes and transmits:
- xb=b1⊕b2
- yb=b2⊕b3
The processor receives A’s full reading and B’s two bits (xb,yb). To reconstruct B’s reading, the processor computes the same XOR operations on A’s reading:
- xa=a1⊕a2
- ya=a2⊕a3
Now the processor compares (xb,yb) with (xa,ya). There are four cases:
Case 1: Both match (xb=xa and yb=ya) A and B are identical. B’s reading is (a1,a2,a3).
Case 2: Only x differs (xb=xa and yb=ya) Since b1⊕b2=a1⊕a2 but b2⊕b3=a2⊕a3, we know b2=a2 and b3=a3, so b1 must differ from a1. B’s reading is (a1,a2,a3), where a1 denotes the negation of a1.
Case 3: Only y differs (xb=xa and yb=ya) By similar reasoning, b3 differs from a3. B’s reading is (a1,a2,a3).
Case 4: Both differ (xb=xa and yb=ya) Since b1⊕b2=a1⊕a2 and b2⊕b3=a2⊕a3, the middle bit b2 must be the one that changed (it appears in both XOR operations). B’s reading is (a1,a2,a3).
Let’s verify with a concrete example. Suppose A’s reading is 101 and B’s reading is 100 (the third bit differs).
B computes: xb=1⊕0=1 and yb=0⊕0=0, and sends (1,0).
The processor computes from A: xa=1⊕0=1 and ya=0⊕1=1.
The processor sees: xb=xa (both are 1) but yb=ya (0 ≠ 1). This is Case 3, so the third bit changed.
The processor reconstructs: (1,0,1)=(1,0,0). Correct!
This encoding works because each bit position has a unique “signature” in the two XOR values:
- b1 appears only in xb
- b3 appears only in yb
- b2 appears in both xb and yb
- No change means xb=xa and yb=ya
This creates four distinct patterns, exactly matching the four possible cases under the “at most one bit different” constraint.
Try These Next
Guessing Hats 3
The king’s challenges are growing crueller. This time, three wise men stand in a room, each wearing either a black or white hat chosen at random by a coin...
Randomised Ice Cream
For Employee Day, your company is offering everyone free ice cream, and you somehow find yourself at the front of the queue. The vendor manning the ice cream...
Stack of Coins 1B
You and your friend stumble on another pirate’s treasure: 99 copper coins and 1 gold coin. As before, these old coins are no longer legal tender, so the copper...