Skip to content

Commit cfea4c3

Browse files
committed
fix: update input validation for n_input_or_gate to require at least two elements
1 parent c98bfe8 commit cfea4c3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

boolean_algebra/or_gate.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ def n_input_or_gate(inputs: list[int]) -> int:
3838
1
3939
>>> n_input_or_gate([1, 1, 1, 1, 1])
4040
1
41+
42+
>>> n_input_or_gate([0, 1])
43+
1
44+
45+
>>> n_input_or_gate([1])
46+
Traceback (most recent call last):
47+
...
48+
ValueError: Input list must contain at least two elements
4149
"""
42-
if len(inputs) > 1:
50+
if len(inputs) < 2:
4351
raise ValueError("Input list must contain at least two elements")
4452

4553
return int(any(inputs))

0 commit comments

Comments
 (0)