Skip to content

Commit 5f629b6

Browse files
Optimize and_gate and nand_gate (#10591)
* Added more optimized sudoku solver algorithm * Added more optimized sudoku solver algorithm and File Renamed * and_gate is Optimized * and_gate is Optimized * and_gate is Optimized * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent fcea18c commit 5f629b6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

boolean_algebra/and_gate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def and_gate(input_1: int, input_2: int) -> int:
2929
>>> and_gate(1, 1)
3030
1
3131
"""
32-
return int((input_1, input_2).count(0) == 0)
32+
return int(input_1 and input_2)
3333

3434

3535
if __name__ == "__main__":

boolean_algebra/nand_gate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def nand_gate(input_1: int, input_2: int) -> int:
2727
>>> nand_gate(1, 1)
2828
0
2929
"""
30-
return int((input_1, input_2).count(0) != 0)
30+
return int(not (input_1 and input_2))
3131

3232

3333
if __name__ == "__main__":

0 commit comments

Comments
 (0)