y2024d17p2 test works

This commit is contained in:
Fabian Schmidt 2024-12-17 15:50:06 +01:00
parent b410fa49ca
commit 5296af36dd

View File

@ -63,17 +63,22 @@ pub fn process_part2(input: &str) -> u32 {
.collect_vec() .collect_vec()
.concat(); .concat();
let mut a = 0; let mut a = 0;
for idx in 1..=orig.len() {
let target = orig[orig.len() - idx..].to_vec();
let mut new_a = a << 3;
loop { loop {
registers.insert("A", a); registers.insert("A", new_a);
let out = exec_program(instructions.clone(), &mut registers); let out = exec_program(instructions.clone(), &mut registers);
if out == orig { println!("target {target:?}");
println!("{orig:?}"); println!("output {out:?}");
println!("{out:?}"); if out == target {
a = new_a;
break; break;
} }
a += 1; new_a += 1;
}
} }
a a
} }