@@ -39,16 +39,15 @@ def parse_input(self, input_data: InputData) -> Input:
3939 if first .isnumeric ():
4040 wires [second ] = int (first )
4141 continue
42- else :
43- in1 , op , in2 = splits [0 ], "SET" , None
42+ in1 , op , in2 = splits [0 ], "SET" , None
4443 elif len (splits ) == 2 :
4544 in1 , op , in2 = splits [1 ], "NOT" , None
4645 else :
4746 in1 , op , in2 = splits [0 ], splits [1 ], splits [2 ]
4847 gates .append ((in1 , op , in2 , second ))
4948 return wires , gates
5049
51- def solve (self , wires : Wires , gates : list [Gate ], wire : str ) -> int :
50+ def solve (self , wires : Wires , gates : list [Gate ], wire : str ) -> int : # noqa: C901
5251 def exec_op (in1 : str , op : str , in2 : str | None , out : str ) -> None :
5352 match op :
5453 case "SET" :
@@ -84,12 +83,12 @@ def exec_op(in1: str, op: str, in2: str | None, out: str) -> None:
8483 q .append ((in1 , op , in2 , out ))
8584 return wires [wire ]
8685
87- def part_1 (self , input : Input ) -> Output1 :
88- wires , gates = input
86+ def part_1 (self , inputs : Input ) -> Output1 :
87+ wires , gates = inputs
8988 return self .solve (wires .copy (), gates , "a" )
9089
91- def part_2 (self , input : Input ) -> Output2 :
92- wires , gates = input
90+ def part_2 (self , inputs : Input ) -> Output2 :
91+ wires , gates = inputs
9392 wires_2 = wires .copy ()
9493 wires_2 ["b" ] = self .solve (wires .copy (), gates , "a" )
9594 return self .solve (wires_2 , gates , "a" )
0 commit comments