y2024d17p2 test works
This commit is contained in:
parent
b410fa49ca
commit
5296af36dd
@ -63,17 +63,22 @@ pub fn process_part2(input: &str) -> u32 {
|
||||
.collect_vec()
|
||||
.concat();
|
||||
let mut a = 0;
|
||||
loop {
|
||||
registers.insert("A", a);
|
||||
let out = exec_program(instructions.clone(), &mut registers);
|
||||
if out == orig {
|
||||
println!("{orig:?}");
|
||||
println!("{out:?}");
|
||||
break;
|
||||
}
|
||||
a += 1;
|
||||
}
|
||||
for idx in 1..=orig.len() {
|
||||
let target = orig[orig.len() - idx..].to_vec();
|
||||
|
||||
let mut new_a = a << 3;
|
||||
loop {
|
||||
registers.insert("A", new_a);
|
||||
let out = exec_program(instructions.clone(), &mut registers);
|
||||
println!("target {target:?}");
|
||||
println!("output {out:?}");
|
||||
if out == target {
|
||||
a = new_a;
|
||||
break;
|
||||
}
|
||||
new_a += 1;
|
||||
}
|
||||
}
|
||||
a
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user