Back

3-Bit Sensors

Hard
Created: February 3, 2026

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⊕b2x_b = b_1 \oplus b_2xb​=b1​⊕b2​ and yb=b2⊕b3y_b = b_2 \oplus b_3yb​=b2​⊕b3​, where ⊕\oplus⊕ denotes XOR.

Let’s say A’s reading is (a1,a2,a3)(a_1, a_2, a_3)(a1​,a2​,a3​) and B’s reading is (b1,b2,b3)(b_1, b_2, b_3)(b1​,b2​,b3​). B computes and transmits:

  • xb=b1⊕b2x_b = b_1 \oplus b_2xb​=b1​⊕b2​
  • yb=b2⊕b3y_b = b_2 \oplus b_3yb​=b2​⊕b3​

The processor receives A’s full reading and B’s two bits (xb,yb)(x_b, y_b)(xb​,yb​). To reconstruct B’s reading, the processor computes the same XOR operations on A’s reading:

  • xa=a1⊕a2x_a = a_1 \oplus a_2xa​=a1​⊕a2​
  • ya=a2⊕a3y_a = a_2 \oplus a_3ya​=a2​⊕a3​

Now the processor compares (xb,yb)(x_b, y_b)(xb​,yb​) with (xa,ya)(x_a, y_a)(xa​,ya​). There are four cases:

Case 1: Both match (xb=xax_b = x_axb​=xa​ and yb=yay_b = y_ayb​=ya​) A and B are identical. B’s reading is (a1,a2,a3)(a_1, a_2, a_3)(a1​,a2​,a3​).

Case 2: Only x differs (xb≠xax_b \neq x_axb​=xa​ and yb=yay_b = y_ayb​=ya​) Since b1⊕b2≠a1⊕a2b_1 \oplus b_2 \neq a_1 \oplus a_2b1​⊕b2​=a1​⊕a2​ but b2⊕b3=a2⊕a3b_2 \oplus b_3 = a_2 \oplus a_3b2​⊕b3​=a2​⊕a3​, we know b2=a2b_2 = a_2b2​=a2​ and b3=a3b_3 = a_3b3​=a3​, so b1b_1b1​ must differ from a1a_1a1​. B’s reading is (a1‾,a2,a3)(\overline{a_1}, a_2, a_3)(a1​​,a2​,a3​), where a1‾\overline{a_1}a1​​ denotes the negation of a1a_1a1​.

Case 3: Only y differs (xb=xax_b = x_axb​=xa​ and yb≠yay_b \neq y_ayb​=ya​) By similar reasoning, b3b_3b3​ differs from a3a_3a3​. B’s reading is (a1,a2,a3‾)(a_1, a_2, \overline{a_3})(a1​,a2​,a3​​).

Case 4: Both differ (xb≠xax_b \neq x_axb​=xa​ and yb≠yay_b \neq y_ayb​=ya​) Since b1⊕b2≠a1⊕a2b_1 \oplus b_2 \neq a_1 \oplus a_2b1​⊕b2​=a1​⊕a2​ and b2⊕b3≠a2⊕a3b_2 \oplus b_3 \neq a_2 \oplus a_3b2​⊕b3​=a2​⊕a3​, the middle bit b2b_2b2​ must be the one that changed (it appears in both XOR operations). B’s reading is (a1,a2‾,a3)(a_1, \overline{a_2}, a_3)(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=1x_b = 1 \oplus 0 = 1xb​=1⊕0=1 and yb=0⊕0=0y_b = 0 \oplus 0 = 0yb​=0⊕0=0, and sends (1,0)(1, 0)(1,0).

The processor computes from A: xa=1⊕0=1x_a = 1 \oplus 0 = 1xa​=1⊕0=1 and ya=0⊕1=1y_a = 0 \oplus 1 = 1ya​=0⊕1=1.

The processor sees: xb=xax_b = x_axb​=xa​ (both are 1) but yb≠yay_b \neq y_ayb​=ya​ (0 ≠ 1). This is Case 3, so the third bit changed.

The processor reconstructs: (1,0,1‾)=(1,0,0)(1, 0, \overline{1}) = (1, 0, 0)(1,0,1)=(1,0,0). Correct!

This encoding works because each bit position has a unique “signature” in the two XOR values:

  • b1b_1b1​ appears only in xbx_bxb​
  • b3b_3b3​ appears only in yby_byb​
  • b2b_2b2​ appears in both xbx_bxb​ and yby_byb​
  • No change means xb=xax_b = x_axb​=xa​ and yb=yay_b = y_ayb​=ya​

This creates four distinct patterns, exactly matching the four possible cases under the “at most one bit different” constraint.

Try These Next