# Build a NAND gate using multiple NAND gates

A question that had popped up in my head once - how many NAND gates would it take to build a larger, "meta-NAND" gate?

Your task is to build a black-box circuit that takes two input wires A and B and returns one output wire that satisfies A NAND B, subject to the following restrictions:

• You must use at least two NAND gates in this construction (and no gates other than NAND).
• You may not have null configurations of gates - that is, systems of gates that are equivalent to a gateless wire. (For example, two NOT gates in series are a null configuration.)
• You cannot have any stray wires (discarded values or constants).

Fewest gates wins.

Three gates. Compute (((A nand A) nand B) nand B). Unlike the four-gate solution above in which three of the four gates compute A nand B, two of them simultaneously, and substituting one of the simultaneous outputs for the other would yield two consecutive inverters, the three-gate solution uses the three gates to compute different functions: "not A", "A or not B", and "A nand B". Only the last gate computes the desired function.

# 4 gates

(A NAND B) AND-using-NAND (A NAND B)

A---NAND        _
\ /    \      / \
X      NAND-<   NAND-->
/ \    /      \_/
B---NAND


# 3 gates

   /-----------\
A-<             \
\-----\       \
\       NAND--
NAND--/
B-<NAND---/

• Duplicate of this answer, (but with A and B switched) Mar 1, 2017 at 21:17