no real progress with day 17
Dieser Commit ist enthalten in:
Ursprung
68e4e93e72
Commit
62a671bc5a
2 geänderte Dateien mit 25 neuen und 10 gelöschten Zeilen
|
@ -1,7 +1,7 @@
|
|||
use advent_of_code::strings::{convert_to_array, parsenumber};
|
||||
#[allow(unused_imports)]
|
||||
use advent_of_code_macros::{include_data, include_example};
|
||||
use log::debug;
|
||||
use log::*;
|
||||
use thousands::Separable;
|
||||
|
||||
include_data!(DATA 2024 17);
|
||||
|
@ -92,6 +92,14 @@ impl GenericCPU {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn reset(&mut self) {
|
||||
self.a = 0;
|
||||
self.b = 0;
|
||||
self.c = 0;
|
||||
self.pos = 0;
|
||||
self.output.clear();
|
||||
}
|
||||
}
|
||||
|
||||
fn get_content(i: &str) -> String {
|
||||
|
@ -129,22 +137,24 @@ fn main() {
|
|||
let output = mem.output.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",");
|
||||
println!("output: {}", output);
|
||||
let mut n: u64 = 0;
|
||||
'numloop: for (pos, num) in mem.ops.iter().cloned().enumerate().map(|(x, y)| (x * 3, y)) {
|
||||
for i in 0..8 {
|
||||
if round(i) == num {
|
||||
println!("Adding {:>18}, the source of {}", i, num);
|
||||
'numloop: for (pos, num) in mem.ops.iter().enumerate().map(|(x, y)| (x * 3, *y)).rev() {
|
||||
for i in 0..64 {
|
||||
println!("Testing round({}) == {}", ((n >> pos) + i).separate_with_underscores(), num);
|
||||
if round((n >> pos) + i) == num {
|
||||
println!("Adding {}, the source of {}", i, num);
|
||||
n += i << pos;
|
||||
continue 'numloop;
|
||||
}
|
||||
}
|
||||
println!("Not Possible to find equivalent of {}", num);
|
||||
}
|
||||
println!("Testing {}", n);
|
||||
println!("Testing {}", format!("{:018b}", n).separate_with_dots());
|
||||
if n >= 48331947862051 {
|
||||
println!("Failed");
|
||||
return;
|
||||
}
|
||||
mem.reset();
|
||||
mem.a = n;
|
||||
mem.b = 0;
|
||||
mem.c = 0;
|
||||
mem.pos = 0;
|
||||
mem.output.clear();
|
||||
mem.generic_process();
|
||||
if mem.output == mem.ops {
|
||||
println!("A: {n}")
|
||||
|
|
5
examples/2024/17.txt
Normale Datei
5
examples/2024/17.txt
Normale Datei
|
@ -0,0 +1,5 @@
|
|||
Register A: 2024
|
||||
Register B: 0
|
||||
Register C: 0
|
||||
|
||||
Program: 0,3,5,4,3,0
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren