File tree Expand file tree Collapse file tree 1 file changed +20
-24
lines changed Expand file tree Collapse file tree 1 file changed +20
-24
lines changed Original file line number Diff line number Diff line change @@ -132,40 +132,36 @@ pub fn part_two(input: &str) -> Option<String> {
132132 return false ;
133133 }
134134
135- if operator == Operator :: Xor {
136- if input. starts_with ( "x" ) || input. starts_with ( "y" ) {
137- if !input_with_operator. contains ( & ( res, Operator :: Xor ) ) {
135+ match operator {
136+ Operator :: Xor => {
137+ if input. starts_with ( "x" ) || input. starts_with ( "y" ) {
138+ if !input_with_operator. contains ( & ( res, Operator :: Xor ) ) {
139+ return true ;
140+ }
141+
142+ if !input_with_operator. contains ( & ( res, Operator :: And ) ) {
143+ return true ;
144+ }
145+ } else if !res. starts_with ( "z" ) {
138146 return true ;
139147 }
140-
141- if !input_with_operator. contains ( & ( res, Operator :: And ) ) {
148+ }
149+ Operator :: And => {
150+ if !input_with_operator. contains ( & ( res, Operator :: Or ) ) {
142151 return true ;
143152 }
144-
145- if res. starts_with ( "z" ) {
153+ }
154+ Operator :: Or => {
155+ if res. starts_with ( "z" ) && res != max_z_name {
146156 return true ;
147157 }
148- } else if !res. starts_with ( "z" ) {
149- return true ;
150- }
151- }
152158
153- if operator == Operator :: And {
154- if res. starts_with ( "z" ) {
155- return true ;
156- }
157-
158- if ( input. starts_with ( "x" ) || input. starts_with ( "y" ) )
159- && !input_with_operator. contains ( & ( res, Operator :: Or ) )
160- {
161- return true ;
159+ if input_with_operator. contains ( & ( res, Operator :: Or ) ) {
160+ return true ;
161+ }
162162 }
163163 }
164164
165- if operator == Operator :: Or && res. starts_with ( "z" ) && res != max_z_name {
166- return true ;
167- }
168-
169165 false
170166 } )
171167 . map ( |( _, _, _, res) | res)
You can’t perform that action at this time.
0 commit comments