We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eafec20 commit cad8919Copy full SHA for cad8919
src/solutions/year2024/day17.rs
@@ -15,16 +15,17 @@ impl Solution for Day17 {
15
fn part_two(&self, input: &str) -> String {
16
let (_, program) = self.parse(input);
17
18
- let mut i = 0;
19
- loop {
+ for i in 0.. {
20
let mut register = RegisterBuilder::default().a(i).build();
21
22
if program.execute_and_watch(&mut register) {
23
return i.to_string();
24
}
25
26
- i += 1;
+ println!("{}", i);
27
+
28
+ unreachable!()
29
30
31
@@ -113,9 +114,21 @@ impl Program {
113
114
&mut output,
115
);
116
117
+ if output.is_empty() {
118
+ continue;
119
+ }
120
121
if expected == output {
122
return true;
123
124
125
+ if expected.len() <= output.len() {
126
+ return false;
127
128
129
+ if expected[0..output.len()] != output {
130
131
132
133
134
false
0 commit comments