Day 10, puzzle 1
This commit is contained in:
16
src/bin/d10p1.rs
Normal file
16
src/bin/d10p1.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use aoc22::{day10, util};
|
||||
|
||||
pub fn main() {
|
||||
let instructions = day10::parse_instructions(&util::parse_input());
|
||||
let mut cpu = day10::CPU::new(instructions);
|
||||
|
||||
let mut sum = 0;
|
||||
for _ in 0..221 {
|
||||
if (cpu.cycle - (20 - 1)) % 40 == 0 {
|
||||
sum += cpu.signal_strength();
|
||||
}
|
||||
cpu.do_cycle().expect("No more instructions?");
|
||||
}
|
||||
|
||||
println!("Sum of 20 + 40n cycles: {}", sum);
|
||||
}
|
||||
Reference in New Issue
Block a user