Skip to content

Instantly share code, notes, and snippets.

@schneems
Created December 27, 2021 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schneems/d791f6883479fc2671fc2e8c23b2b568 to your computer and use it in GitHub Desktop.
Save schneems/d791f6883479fc2671fc2e8c23b2b568 to your computer and use it in GitHub Desktop.
let mut samples: Vec<i64> = Vec::with_capacity(100_000);
let mut rng = rand::thread_rng();
while samples.len() < 100_000 {
samples.push(rng.gen_range(11111111111111..=99999999999999));
}
let mut answers = Vec::with_capacity(100_000);
let instructions = parse(include_str!("../input.txt"));
for num in samples {
println!("{}", num);
let mut alu = ALU {
x: 0,
y: 0,
z: 0,
w: 0,
};
run_commands(&mut alu, &instructions, num);
if alu.z == 0 {
println!("{}", num);
answers.push(num);
break;
}
}
answers.sort();
println!("done");
for a in answers.iter() {
println!("{}", a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment