17 lines
420 B
Rust
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);
|
|
}
|