1use crate::assembunny::Interpreter;
2use utils::prelude::*;
3
4#[derive(Clone, Debug)]
15pub struct Day12 {
16 interpreter: Interpreter<false, false>,
17}
18
19impl Day12 {
20 pub fn new(input: &str, _: InputType) -> Result<Self, InputError> {
21 Ok(Self {
22 interpreter: Interpreter::new(input)?,
23 })
24 }
25
26 #[must_use]
27 pub fn part1(&self) -> i32 {
28 self.interpreter.execute([0; 4])
29 }
30
31 #[must_use]
32 pub fn part2(&self) -> i32 {
33 self.interpreter.execute([0, 0, 1, 0])
34 }
35}
36
37examples!(Day12 -> (i32, i32) [
38 {
39 input: "cpy 41 a\n\
40 inc a\n\
41 inc a\n\
42 dec a\n\
43 jnz a 2\n\
44 dec a",
45 part1: 42
46 },
47]);