Build the Wheat Wizard's stove using 2-input NAND gates. The solution with the fewest NAND gates wins.

Externally, it works in the following way: (the first line is added from the original spec for physical output)

  • It has 10 levels, from 0 to 9. The display has 9 lights, and if the current level is L, exactly L lights from the left are on and the rest are off.
  • Two buttons, labeled + and -, are used to control the temperature level.
  • Pressing + changes the level as follows:
    • 0 becomes 9
    • 9 becomes 0
    • any other number is incremented
  • Pressing - changes the level as follows:
    • 0 becomes 4
    • any other number is decremented

In summary, the circuit must behave as a sequential circuit with two inputs (the buttons) and 9 outputs (the lights).


  • You can use a clock signal generator if you want, at no cost in score.
  • You don't need to make the power-up behavior correct.
  • You will need at least a few latches or flip-flops in your circuit, in order to keep track of the current temperature level. Different latches/flip-flops cost different number of NAND gates, which is included in your score. It is your job to choose the flip-flop that gives the fewest NAND gates overall.
  • One button press must affect the level exactly once, but you can choose exactly when the level changes according to input, e.g.
    • when the button is pressed
    • when the button is released
    • at the first clock tick (you can choose rising or falling edge) while the button is pressed (that button is disabled until release) - you can assume the clock cycle is short enough for this to register
  • You may assume both buttons won't be pressed simultaneously.
  • 1
    \$\begingroup\$ I feel like this could use a clearer description of the available elements, how they are combined and how they interact. \$\endgroup\$
    – Wheat Wizard
    Oct 26, 2021 at 13:44
  • \$\begingroup\$ @GrainGhost The available elements are a bunch of 2-input NAND gates, plus a single optional clock generator and the necessary I/O devices (2 buttons and 9 lights) as given in the spec. You're supposed to build everything else using NAND gates only, including the memory, memory update logic, and output logic. \$\endgroup\$
    – Bubbler
    Oct 27, 2021 at 4:05
  • 1
    \$\begingroup\$ What I mean is that because this is an abstract system you should actually explain how it works. What real world considerations carry over? e.g. Are wires instantaneous? Can you split a wire indefinitely or are we going to have to worry about effects this has on current? What happens when we wire nand gates in non-consistent ways? Explaining the system concretely would answer these and many more questions. \$\endgroup\$
    – Wheat Wizard
    Oct 27, 2021 at 12:30
  • \$\begingroup\$ Can we connect two wires to make a 0-NAND OR gate? \$\endgroup\$
    – Seggan
    Apr 18, 2022 at 17:35

1 Answer 1


CircuitVerse, 455 NANDs

  • 1x NOT (1 NANDs)
  • 2x AND (4 NANDs)
  • 3x OR (9 NANDs)
  • 1x 4-bit 2x4 multiplexer (96 NANDs)
  • 1x 4x1 Decoder (6 NANDs)
  • 1x 4-bit adder (108 NANDs)
  • 1x 2-bit Memory (54 NANDS)
  • 1x 4-bit Memory (108 NANDs)
  • 1x (4-bit) Is 1 (9 NANDs)
  • 1x (4-bit) Is 10 (8 NANDs)
  • 1x (4-bit) Is neg (2 NANDs)
  • 1x 1-9 encoder (50 NANDs)

Total = 455

Try it out online! (version 1.1)

version 1.0 (NANDs 543)

  • 2
    \$\begingroup\$ Wow, TIL there's a platform where you can share live circuit schematics, with buttons and lightbulbs (diodes?) :) Currently this mostly works as expected, except for the output method - the challenge says 9 lightbulbs instead of 10, and "if the current level is L, exactly L lights from the left are on and the rest are off", not "the L-th light is on and the rest are off". \$\endgroup\$
    – Bubbler
    Oct 27, 2021 at 4:00
  • \$\begingroup\$ Oh, I might make a copy of the circuit (as to not change the solution posted) and fix that then. thanks for letting me know! I thought of a way to take off some more NAND gates as well so I'll do both at once :) \$\endgroup\$ Oct 27, 2021 at 9:39
  • 1
    \$\begingroup\$ Also, for anybody thinking about using the circuitverse website, know that it crashes a lot! Save often, very often! Expect to lose progress if you're not saving every couple of minutes. \$\endgroup\$ Oct 27, 2021 at 10:13
  • 1
    \$\begingroup\$ On page 3 of this pdf is a full adder with just 9 NANDs, that should help with the expensive 4-bit adders \$\endgroup\$
    – ovs
    Oct 27, 2021 at 13:32
  • \$\begingroup\$ @ovs In the PDF, it uses NAND gates which have more than 2 inputs. In the challenge problem, it mentions that you are only allowed to use 2-input NAND gates. I appreciate the PDF though. \$\endgroup\$ Oct 27, 2021 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.