I seem to have learned this shit before there were (affordable) logic circuits. NAND was simply a transistor (or relay (or tube)) with punch of diodes pulling the gate or base down. We learned to use "Karnaugh Maps" to simplify the logic circutry to these bare NANDs. https://en.wikipedia.org/wiki/Karnaugh_map