-use std::fs;\r
-use std::path::Path;\r
-use std::str::FromStr;\r
+use std::{fs, path::Path, str::FromStr};\r
\r
pub fn read_list_of_numbers<P, T>(file: P, sep: &str) -> Vec<T>\r
where\r
-use std::iter::Iterator;\r
-use std::iter::FromIterator;\r
-use std::collections::HashSet;\r
-use std::collections::HashMap;\r
+use std::{collections::{HashMap, HashSet}, iter::{Iterator, FromIterator}};\r
\r
pub fn split_movements(movements: &str) -> Vec<&str> {\r
movements.split(',').collect()\r
\r
fn set_range(from: usize, to: usize, value: u8, digits: &mut Digits) {\r
for d in &mut digits[from .. to] { *d = value; }\r
- };\r
+ }\r
\r
for i in (1 .. l).rev() {\r
if digits[i - 1] < digits[i] {\r
-use std::collections::HashMap;
-use std::cmp;
+use std::{cmp, collections::HashMap};
// All planets indexing their parent (planet -> parent).
type Orbits = HashMap<String, String>;
-use super::intcode;\r
+use std::sync::{Arc, Barrier, mpsc::{self, Sender, Receiver}, atomic::{AtomicI64, Ordering}};\r
+\r
use itertools::Itertools;\r
-use std::sync::{ Arc, Barrier, mpsc::{ self, Sender, Receiver }, atomic::{ AtomicI64, Ordering } };\r
use threadpool::ThreadPool;\r
\r
+use super::intcode;\r
+\r
fn last_thruster_signal(code: &[i64], phase_setting: &[i64]) -> i64 {\r
phase_setting.iter().fold(0, |last_output, input| intcode::execute_op_code(&code, &[*input, last_output])[0])\r
}\r
use std::collections::HashMap;\r
+\r
use super::intcode;\r
\r
enum NextCommand {\r
-use std::ops::AddAssign;
-use std::cmp::Ordering;
+use std::{cmp::Ordering, ops::AddAssign};
#[derive(Debug, Copy, Clone)]
pub struct Vector3D {
-use super::intcode;
-use std::cmp::Ordering;
-use std::convert::TryFrom;
+use std::{cmp::Ordering, convert::TryFrom};
+
use itertools::Itertools;
use num_enum::TryFromPrimitive;
+use super::intcode;
+
// Not neccesary, to try to parse enum in Rust.
#[derive(Debug, Eq, PartialEq, TryFromPrimitive)]
#[repr(u8)]
+use std::{collections::{HashMap, HashSet}, iter::FromIterator};\r
+\r
use super::intcode;\r
-use std::iter::FromIterator;\r
-use std::collections::HashMap;\r
-use std::collections::HashSet;\r
\r
#[derive(Debug, Eq, PartialEq, Copy, Clone)]\r
enum LocationState {\r
-use super::intcode;\r
+use std::{collections::HashSet, convert::TryFrom, ops::Range};\r
+\r
use itertools::Itertools;\r
-use std::collections::HashSet;\r
-use std::convert::TryFrom;\r
-use std::ops::Range;\r
+\r
+use super::intcode;\r
\r
#[derive(PartialEq, Eq, Copy, Clone, Debug)]\r
enum Direction { Up, Left, Down, Right }\r
Mode::Immediate => code[position],\r
Mode::Relative => if (code[position] + relative_base) as usize >= code.len() { 0 } else { code[(code[position] + relative_base) as usize] }\r
}\r
- };\r
+ }\r
\r
fn write(position: usize, value: i64, code: &mut Vec<i64>, mode: Mode, relative_base: i64) {\r
let ref_position =\r
} else {\r
cursor + 3\r
}\r
- };\r
+ }\r
\r
loop {\r
if io.halt() { break; }\r