File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -15,16 +15,17 @@ impl Solution for Day17 {
1515 fn part_two ( & self , input : & str ) -> String {
1616 let ( _, program) = self . parse ( input) ;
1717
18- let mut i = 0 ;
19- loop {
18+ for i in 0 .. {
2019 let mut register = RegisterBuilder :: default ( ) . a ( i) . build ( ) ;
2120
2221 if program. execute_and_watch ( & mut register) {
2322 return i. to_string ( ) ;
2423 }
2524
26- i += 1 ;
25+ println ! ( "{}" , i ) ;
2726 }
27+
28+ unreachable ! ( )
2829 }
2930}
3031
@@ -113,9 +114,21 @@ impl Program {
113114 & mut output,
114115 ) ;
115116
117+ if output. is_empty ( ) {
118+ continue ;
119+ }
120+
116121 if expected == output {
117122 return true ;
118123 }
124+
125+ if expected. len ( ) <= output. len ( ) {
126+ return false ;
127+ }
128+
129+ if expected[ 0 ..output. len ( ) ] != output {
130+ return false ;
131+ }
119132 }
120133
121134 false
You can’t perform that action at this time.
0 commit comments