XOR gate in redstone

On when the two inputs differ. Needs four torches and a bit of patience. Footprint 5 wide × 5 deep × 2 tall. Build it block by block in Minecraft.

How to build it

XOR is the most involved of the two-input gates. One compact wiring: (A ∧ ¬B) ∨ (¬A ∧ B). Build two ANDs from mixed inverted/uninverted inputs, then OR them.

Simpler recipe (four-torch XOR):

  1. Invert A (torch on a block → ¬A).
  2. Invert B (torch on a block → ¬B).
  3. Build a block powered by A and ¬B. Torch on its side outputs A ∧ ¬B.
  4. Build a block powered by ¬A and B. Torch outputs ¬A ∧ B.
  5. Merge those two torches' dust → that's the XOR output.

Why it works

A ⊕ B = (A ∧ ¬B) ∨ (¬A ∧ B). Each half of the expression fires when exactly one input is on; the OR combines them.

Variations

The four-torch version shown here is the go-to for explaining how XOR works; compact variants come later.

Gotchas