aoc22/src/bin/d10p1.rs
2022-12-15 15:44:37 +01:00

17 lines
420 B
Rust

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);
}