pub fn y22d10p1(input: &str) -> i32
Expand description
The solution for part one of the day ten challenge.
This is relatively straightforward after computing the state of the
register for each cycle. It just involves a little bit of math. The signal
strength is computed by the value of the register at cycle 20
and then
again every 40
cycles thereafter. So we start by calculating how many
additional checks we need to make (the length of the cycles vector minus
20
to account for the first check divided by 40
). Then for each check
we add to the signal strength the value of the register times the cycle
(index/number).
§Example
// probably read this from the input file...
let input = "noop\naddx 3\naddx -5";
assert_eq!(y22d10p1(input), 0);