Skip to content

Commit 2c6c4b2

Browse files
committed
fix: correct input length check in n_input_nand_gate function to raise error for insufficient elements
1 parent 4ca9e04 commit 2c6c4b2

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

boolean_algebra/nand_gate.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,17 @@ def n_input_nand_gate(inputs: list[int]) -> int:
4141
1
4242
>>> n_input_nand_gate([1, 0, 0, 0, 0])
4343
1
44+
45+
>>> n_input_nand_gate([1, 1])
46+
0
47+
48+
>>> n_input_nand_gate([1])
49+
Traceback (most recent call last):
50+
...
51+
ValueError: Input list must contain at least two elements
4452
"""
4553

46-
if len(inputs) > 1:
54+
if len(inputs) < 2:
4755
raise ValueError("Input list must contain at least two elements")
4856

4957
return int(not all(inputs))

0 commit comments

Comments
 (0)