diff --git a/2016/inputs/25.txt b/2016/inputs/25.txt new file mode 100644 index 0000000..a9734a4 --- /dev/null +++ b/2016/inputs/25.txt @@ -0,0 +1,30 @@ +cpy a d +cpy 7 c +cpy 362 b +inc d +dec b +jnz b -2 +dec c +jnz c -5 +cpy d a +jnz 0 0 +cpy a b +cpy 0 a +cpy 2 c +jnz b 2 +jnz 1 6 +dec b +dec c +jnz c -4 +inc a +jnz 1 -7 +cpy 2 b +jnz c 2 +jnz 1 4 +dec b +dec c +jnz 1 -4 +jnz 0 0 +out b +jnz a -19 +jnz 1 -21 diff --git a/2016/src/day25.rs b/2016/src/day25.rs new file mode 100644 index 0000000..dc2c2e1 --- /dev/null +++ b/2016/src/day25.rs @@ -0,0 +1,43 @@ +use std::io; +use common; + +#[derive(Default)] +pub struct Day25 { +} + +impl Day25 { + + pub fn new() -> Day25 { + Default::default() + } + +} + +impl common::Solution for Day25 { + + fn part1(&mut self, _input: &mut io::Read) -> String { + let initial = 0b101010101010 - 362 * 7; + println!("Initial value: {}", initial); + sender_program(initial); + unreachable!(); + } +} + +/// This function is an approximation of what the original code is doing. +pub fn sender_program(mut a: i32) { + // Placeholder variables + let mut b = 0; + let mut d = 0; + + d = a; + d += 362 * 7; + loop { + if a == 0 { + a = d; + } + b = a; + a = b / 2; + b = b % 2; + println!("{}", b); + } +} diff --git a/2016/src/main.rs b/2016/src/main.rs index 24ad94c..885eecc 100644 --- a/2016/src/main.rs +++ b/2016/src/main.rs @@ -13,6 +13,7 @@ pub mod day15; pub mod day16; pub mod day23; pub mod day24; +pub mod day25; fn get_impl(day: &str) -> Box { match day.parse() { @@ -22,6 +23,7 @@ fn get_impl(day: &str) -> Box { Ok(16) => { Box::new(day16::Day16::new()) } Ok(23) => { Box::new(day23::Day23::new()) } Ok(24) => { Box::new(day24::Day24::new()) } + Ok(25) => { Box::new(day25::Day25::new()) } Ok(val) => { panic!("Unimplemented day {}", val) },