aboutsummaryrefslogtreecommitdiff
path: root/2022/10/common.rs
diff options
context:
space:
mode:
Diffstat (limited to '2022/10/common.rs')
-rw-r--r--2022/10/common.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/2022/10/common.rs b/2022/10/common.rs
new file mode 100644
index 0000000..c2216a0
--- /dev/null
+++ b/2022/10/common.rs
@@ -0,0 +1,13 @@
1pub enum Instruction {
2 Add(i64),
3 Noop
4}
5
6pub fn read_instruction(line: &str) -> Instruction {
7 if &line[..4] == "addx" {
8 let n = line[5..line.len()-1].parse::<i64>().unwrap();
9 Instruction::Add(n)
10 } else {
11 Instruction::Noop
12 }
13}

Generated with cgit - Back to sebastiano.tronto.net