summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2016-12-12 00:35:32 -0500
committerJune McEnroe <june@causal.agency>2020-11-22 00:14:25 -0500
commitf4be1e12ec6da42570d9c542b4752bca2fabe3c6 (patch)
treebd9b841f1137f42e48794af806449ab984899dae
parentDay 12 (diff)
downloadaoc-f4be1e12ec6da42570d9c542b4752bca2fabe3c6.tar.gz
aoc-f4be1e12ec6da42570d9c542b4752bca2fabe3c6.zip
Day 12 part 2
Diffstat (limited to '')
-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()));
 }
href='/pounce/commit/contrib/palaver/notify.c?h=2.4&id=f4d06c101fd0a66d01ca964004a7bba5e63e01ae&follow=1'>contrib/palaver: Only allow HTTPSJune McEnroe 2020-08-25Support the pounce_env rc variableJune McEnroe 2020-08-25Remove deprecated option namesJune McEnroe 2020-08-25Document configuration and data file searchJune McEnroe 2020-08-24Use dataOpen for save fileJune McEnroe 2020-08-24Use configOpen to load localCAJune McEnroe 2020-08-24Use configPath to load client cert/privJune McEnroe 2020-08-24Use configOpen in getopt_configJune McEnroe 2020-08-24Import xdg.c from catgirlJune McEnroe 2020-08-23Replace “RAND_bytes” by “getentropy”Issam E. Maghni 2020-08-16contrib/palaver: Add no message preview flagsJune McEnroe 2020-08-13contrib/palaver: Don't set channel for PMsJune McEnroe 2020-08-13Fix unintended interception of NICK after registrationJune McEnroe 2020-08-12Add Additional Components section to READMEJune McEnroe 2020-08-12Document -L / palaver optionJune McEnroe 2020-08-11contrib/palaver: Document service configurationJune McEnroe 2020-08-11contrib/palaver: Add install target and rc scriptJune McEnroe 2020-08-11contrib/palaver: Implement command and notificationsJune McEnroe