summary refs log tree commit diff homepage
path: root/src
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2016-12-12 00:35:32 -0500
committerJune McEnroe <june@causal.agency>2020-11-22 00:14:25 -0500
commit1d438e15c63f6b6a154f17d662fea1a37263fbce (patch)
treea82fe71ebed0ffdd7a3c68fced7151a8b07a00a0 /src
parentDay 12 (diff)
downloadaoc-1d438e15c63f6b6a154f17d662fea1a37263fbce.tar.gz
aoc-1d438e15c63f6b6a154f17d662fea1a37263fbce.zip
Day 12 part 2
Diffstat (limited to 'src')
-rw-r--r--src/bin/day12.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/bin/day12.rs b/src/bin/day12.rs
index 64b09f8..6655947 100644
--- a/src/bin/day12.rs
+++ b/src/bin/day12.rs
@@ -108,17 +108,25 @@ impl Vm {
     }
 }
 
-fn solve(input: &str) -> i32 {
+fn solve1(input: &str) -> i32 {
     let mut vm: Vm = input.parse().unwrap();
     while vm.step() { }
     vm.registers[0]
 }
 
+fn solve2(input: &str) -> i32 {
+    let mut vm: Vm = input.parse().unwrap();
+    vm.registers[2] = 1;
+    while vm.step() { }
+    vm.registers[0]
+}
+
 fn main() {
     let mut input = String::new();
     io::stdin().read_to_string(&mut input).unwrap();
 
-    println!("Part 1: {}", solve(&input));
+    println!("Part 1: {}", solve1(&input));
+    println!("Part 2: {}", solve2(&input));
 }
 
 #[test]
@@ -131,5 +139,5 @@ dec a
 jnz a 2
 dec a
 ";
-    assert_eq!(42, solve(input.trim()));
+    assert_eq!(42, solve1(input.trim()));
 }