aboutsummaryrefslogtreecommitdiff
path: root/2022/10/common.rs
blob: c2216a0b565b260b68016306d4a465c604245d18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
pub enum Instruction {
    Add(i64),
    Noop
}

pub fn read_instruction(line: &str) -> Instruction {
    if &line[..4] == "addx" {
        let n = line[5..line.len()-1].parse::<i64>().unwrap();
        Instruction::Add(n)
    } else {
        Instruction::Noop
    }
}

Generated with cgit - Back to sebastiano.tronto.net