Function advent_solutions::advent2017::day18::part1 [] [src]

pub fn part1(instructions: &[Instruction]) -> isize

For example:

set a 1
add a 2
mul a a
mod a 5
snd a
set a 0
rcv a
jgz a -1
set a 1
jgz a -2

At the time the recover operation is executed, the frequency of the last sound played is 4.

let instructions = Instruction::list_from_bytes(input.as_bytes())
    .to_full_result()
    .expect("Error parsing instructions");

assert_eq!(part1(&instructions), 4);

What is the value of the recovered frequency (the value of the most recently played sound) the first time a rcv instruction is executed with a non-zero value?