-pub fn execute_op_code_with_state_fixed(code : &mut [i32]) -> i32 {\r
+pub fn execute_op_code_with_state_fixed(code: &mut [i32]) -> i32 {\r
code[1] = 12;\r
code[2] = 2;\r
execute_op_code(code)\r
}\r
\r
-fn execute_op_code(code : &mut [i32]) -> i32 {\r
+fn execute_op_code(code: &mut [i32]) -> i32 {\r
let mut cursor = 0;\r
loop {\r
match code[cursor] {\r
}\r
}\r
\r
-pub fn find_noun_and_verb(code : &[i32]) -> i32 {\r
+pub fn find_noun_and_verb(code: &[i32]) -> i32 {\r
loop {\r
for verb in 0..=99 {\r
for noun in 0..=99 {\r
--- /dev/null
+fn read_code(code: i32) -> (i32, Vec<bool>) {\r
+\r
+}\r
+\r
+fn execute_op_code(code: &mut [i32], input: &[i32]) -> Vec<i32> {\r
+ let mut cursor = 0;\r
+ let mut output = Vec::<i32>::new();\r
+ loop {\r
+ match code[cursor] {\r
+ 1 => code[code[cursor + 3] as usize] = code[code[cursor + 1] as usize] + code[code[cursor + 2] as usize],\r
+ 2 => code[code[cursor + 3] as usize] = code[code[cursor + 1] as usize] * code[code[cursor + 2] as usize],\r
+ 99 => return code[0],\r
+ _ => panic!("Unkown code: {}", code[cursor])\r
+ }\r
+ cursor += 4;\r
+ }\r
+}\r
+\r
+\r
+\r
+\r
+#[cfg(test)]\r
+mod tests {\r
+ use super::*;\r
+\r
+ #[test]\r
+ fn part1() {\r
+ }\r
+\r
+ #[test]\r
+ fn part2() {\r
+ }\r
+}
\ No newline at end of file