File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,32 @@ def imply_gate(input_1: int, input_2: int) -> int:
3333 return int (input_1 == 0 or input_2 == 1 )
3434
3535
36+ def recursive_imply_list (input_list : list [int ]) -> int :
37+ """
38+ Recursively calculates the implication of a list.
39+ Strictly The Implication is Applied Consecuteivly left to right:
40+ ( (a -> b) -> c ) -> d ...
41+
42+ >>> recursive_imply_list([])
43+ 1
44+ >>> recursive_imply_list([0])
45+ 0
46+ >>> recursive_imply_list([1])
47+ 1
48+ >>> recursive_imply_list([1, 0, 1])
49+ 1
50+ >>> recursive_imply_list([1, 1, 0])
51+ 0
52+ """
53+ if not input_list :
54+ return 1
55+ if len (input_list ) == 1 :
56+ return input_list [0 ]
57+ first_implication = imply_gate (input_list [0 ], input_list [1 ])
58+ new_list = [first_implication , * input_list [2 :]]
59+ return recursive_imply_list (new_list )
60+
61+
3662if __name__ == "__main__" :
3763 import doctest
3864
You can’t perform that action at this time.
0 commit comments