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):
Invert A (torch on a block → ¬A).
Invert B (torch on a block → ¬B).
Build a block powered by A and¬B. Torch on its side outputs
A ∧ ¬B.
Build a block powered by ¬Aand B. Torch outputs ¬A ∧ B.
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
Comparator XOR: two comparators in subtraction mode can produce
XOR in a tight 2×3 footprint. Faster to build and smaller, but the
comparator mechanics are less intuitive.
Piston XOR: moves a block between two positions. Great visual,
slow, and uses quasi-connectivity tricks (Java edition only).
The four-torch version shown here is the go-to for explaining how XOR
works; compact variants come later.
Gotchas
XOR has 3–4 ticks of delay, more than most gates. If the inputs
arrive at different times, you may see transient glitches. Add a
repeater on the faster input to align them.
This layout is a conceptual schematic. Real builds interleave
blocks to save space — treat the grid as a wiring diagram, not a
literal 1:1 block plan.