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
Planting Trees 2
A few weeks after your first job, the mathematics professor calls you back. She was so pleased with your creative solution to the four-tree problem that she...
Chain Link 2
An apprentice is working for you, the village’s master blacksmith, for 21 days. For payment, you have agreed to give him a gold chain with 21 links, one link...
Treasure and Locks
Thirteen pirates put their treasure in a chest. They want the chest to be openable whenever a majority of them (7 or more) agree, but not when only a minority...