Skip to content

Commit f0b7ea4

Browse files
committed
feat: add n_input_or_gate function to calculate OR of multiple inputs
1 parent 791deb4 commit f0b7ea4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

boolean_algebra/or_gate.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ def or_gate(input_1: int, input_2: int) -> int:
2929
return int((input_1, input_2).count(1) != 0)
3030

3131

32+
def n_input_or_gate(inputs: list[int]) -> int:
33+
"""
34+
Calculate OR of a list of input values
35+
>>> n_input_or_gate([0, 0, 0, 0, 0])
36+
0
37+
>>> n_input_or_gate([0, 1, 0, 0, 0])
38+
1
39+
>>> n_input_or_gate([1, 1, 1, 1, 1])
40+
1
41+
"""
42+
return int(any(inputs))
43+
44+
3245
if __name__ == "__main__":
3346
import doctest
3447

0 commit comments

Comments
 (0)