-
-
Save schneems/d791f6883479fc2671fc2e8c23b2b568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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