start_position: (i32, i32),\r
start_dir: Direction,\r
crossings: Vec<(i32, i32)>,\r
+\r
dir_commands: Vec<MovementCommand>,\r
+ commands_sequences: [Vec<(i32, i32)>; 3], // 3 sequences: A, B and C.\r
}\r
\r
impl RobotTrackingSystem {\r
start_dir: Direction::Up,\r
crossings: Vec::<(i32, i32)>::new(),\r
dir_commands: Vec::<MovementCommand>::new(),\r
+ commands_sequences: [Vec::<(i32, i32)>::new(), Vec::<(i32, i32)>::new(), Vec::<(i32, i32)>::new()],\r
}\r
}\r
\r
break;\r
}\r
}\r
+\r
+ fn find_sequences(&mut self) {\r
+ if !self.commands_sequences[0].is_empty() { return; }\r
+\r
+\r
+ }\r
}\r
\r
impl intcode::IO for RobotTrackingSystem {\r
- // Read instructions \r
+ // Read instructions\r
fn read(&mut self) -> i64 {\r
self.build_board_from_output();\r
- 42 // TODO: part2.\r
+ self.find_sequences();\r
+ 42\r
}\r
\r
// Send to the output channel.\r
intcode::execute_op_code_with_custom_io(code, &mut rts);\r
\r
}\r
+\r
+#[cfg(test)]\r
+mod tests {\r
+ use super::*;\r
+ use itertools::Itertools;\r
+\r
+ #[test]\r
+ fn foo() {\r
+ let array = vec![1, 2, 3];\r
+ let s: i32 = array.iter().sum();\r
+ dbg!(s);\r
+ let mut combinations: Vec<Vec<i32>> = (3..=7).combinations_with_replacement(3).sorted_by(|v1, v2| {\r
+ let s1: i32 = v1.iter().sum();\r
+ let s2: i32 = v2.iter().sum();\r
+ s1.cmp(&s2)\r
+ }).collect();\r
+ println!("{:?}", combinations);\r
+ }\r
+}
\ No newline at end of file