diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-27 09:53:33 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-27 09:53:33 +0200 |
| commit | 0e6bebb63d5795ca9143b9713d1d82ebec8d7e03 (patch) | |
| tree | 3ca39b2e485247609168d0a1b3e986f1e824a6d6 /2022/10/common.rs | |
| parent | fa26f694d8cf98272763952a698301ee9935c19e (diff) | |
| download | aoc-0e6bebb63d5795ca9143b9713d1d82ebec8d7e03.tar.gz aoc-0e6bebb63d5795ca9143b9713d1d82ebec8d7e03.zip | |
Day 10
Diffstat (limited to '2022/10/common.rs')
| -rw-r--r-- | 2022/10/common.rs | 13 |
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 @@ | |||
| 1 | pub enum Instruction { | ||
| 2 | Add(i64), | ||
| 3 | Noop | ||
| 4 | } | ||
| 5 | |||
| 6 | pub 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 | } | ||
