From: Greg Burri Date: Sun, 5 Jan 2020 10:46:02 +0000 (+0100) Subject: Preparing for day 17 part 2 X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=7157d0a6a148ada664e7b9f4b567b85dfe35a985;p=advent_of_code_2019.git Preparing for day 17 part 2 --- diff --git a/src/day17.rs b/src/day17.rs index 52d5988..8aae48a 100644 --- a/src/day17.rs +++ b/src/day17.rs @@ -31,7 +31,9 @@ pub struct RobotTrackingSystem { start_position: (i32, i32), start_dir: Direction, crossings: Vec<(i32, i32)>, + dir_commands: Vec, + commands_sequences: [Vec<(i32, i32)>; 3], // 3 sequences: A, B and C. } impl RobotTrackingSystem { @@ -43,6 +45,7 @@ impl RobotTrackingSystem { start_dir: Direction::Up, crossings: Vec::<(i32, i32)>::new(), dir_commands: Vec::::new(), + commands_sequences: [Vec::<(i32, i32)>::new(), Vec::<(i32, i32)>::new(), Vec::<(i32, i32)>::new()], } } @@ -136,13 +139,20 @@ impl RobotTrackingSystem { break; } } + + fn find_sequences(&mut self) { + if !self.commands_sequences[0].is_empty() { return; } + + + } } impl intcode::IO for RobotTrackingSystem { - // Read instructions + // Read instructions fn read(&mut self) -> i64 { self.build_board_from_output(); - 42 // TODO: part2. + self.find_sequences(); + 42 } // Send to the output channel. @@ -166,3 +176,22 @@ pub fn part2(code: &[i64]) { intcode::execute_op_code_with_custom_io(code, &mut rts); } + +#[cfg(test)] +mod tests { + use super::*; + use itertools::Itertools; + + #[test] + fn foo() { + let array = vec![1, 2, 3]; + let s: i32 = array.iter().sum(); + dbg!(s); + let mut combinations: Vec> = (3..=7).combinations_with_replacement(3).sorted_by(|v1, v2| { + let s1: i32 = v1.iter().sum(); + let s2: i32 = v2.iter().sum(); + s1.cmp(&s2) + }).collect(); + println!("{:?}", combinations); + } +} \ No newline at end of file