add: broken stuff

This commit is contained in:
Charles
2024-12-16 22:49:41 -08:00
parent eec91476dc
commit 2f301a3a51
+9 -11
View File
@@ -1,4 +1,9 @@
use std::{collections::{HashMap, HashSet}, process::exit, thread, time::Duration}; use std::{
collections::{HashMap, HashSet},
process::exit,
thread,
time::Duration,
};
use advent_of_code_2024::{make_main, SResult}; use advent_of_code_2024::{make_main, SResult};
use regex::Regex; use regex::Regex;
@@ -124,29 +129,22 @@ fn solve(lines: Vec<String>) -> SResult<(usize, usize)> {
let pool = ThreadPool::new(20); let pool = ThreadPool::new(20);
//let mut n = 3536000000; //let mut n = 3536000000;
let mut n = 0; let mut n = 0;
let mut prev_best = 0;
let program: &'static mut [usize] = program.leak(); let program: &'static mut [usize] = program.leak();
loop { loop {
{
let n = n;
let program: &'static [usize] = program;
pool.execute(move || {
let values = State::new(&program, [n, 0, 0]).run_to_end(); let values = State::new(&program, [n, 0, 0]).run_to_end();
if values.len() > 4 { if values.len() > prev_best {
println!("{} => {:?}", n, values); println!("{} => {:?}", n, values);
prev_best = values.len();
} }
while &values == program { while &values == program {
println!("finished at {}", n); println!("finished at {}", n);
//exit(n as i32); //exit(n as i32);
} }
});
}
n += 1; n += 1;
if n % 1000000 == 0 { if n % 1000000 == 0 {
println!("n = {}", n); println!("n = {}", n);
} }
while pool.queued_count() > 10000 {
thread::sleep(Duration::from_millis(10));
}
} }
Ok((values.len(), n)) Ok((values.len(), n))
} }