blob: cdab2839edcd92e6968b8d598fc4902bb574588e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
mod common;
use common::*;
fn main() {
let mut x: i64 = 1;
let mut cycles: usize = 0;
let mut step: usize = 20;
let mut score: i64 = 0;
let mut line = String::new();
while std::io::stdin().read_line(&mut line).unwrap() > 0 {
let oldx = x;
match read_instruction(&line) {
Instruction::Add(n) => { x += n; cycles += 2; },
Instruction::Noop => { cycles += 1; }
}
if cycles >= step {
score += oldx * (step as i64);
step += 40;
}
line.clear();
}
println!("{score}");
}
|