diff options
Diffstat (limited to '2015')
-rw-r--r-- | 2015/rs/code/eight/src/main.rs | 2 | ||||
-rw-r--r-- | 2015/rs/code/five/src/main.rs | 4 | ||||
-rw-r--r-- | 2015/rs/code/four/src/main.rs | 2 | ||||
-rw-r--r-- | 2015/rs/code/nine/src/main.rs | 19 | ||||
-rw-r--r-- | 2015/rs/code/one/src/main.rs | 2 | ||||
-rw-r--r-- | 2015/rs/code/six/src/main.rs | 2 | ||||
-rw-r--r-- | 2015/rs/code/three/src/main.rs | 2 | ||||
-rw-r--r-- | 2015/rs/code/two/src/main.rs | 2 |
8 files changed, 17 insertions, 18 deletions
diff --git a/2015/rs/code/eight/src/main.rs b/2015/rs/code/eight/src/main.rs index 6917a54..1d582d7 100644 --- a/2015/rs/code/eight/src/main.rs +++ b/2015/rs/code/eight/src/main.rs @@ -1,4 +1,4 @@ -static INPUT: &'static str = include_str!("input.txt"); +static INPUT: &str = include_str!("input.txt"); #[derive(Copy, Clone)] enum ParseState { diff --git a/2015/rs/code/five/src/main.rs b/2015/rs/code/five/src/main.rs index eeafd42..3c4872c 100644 --- a/2015/rs/code/five/src/main.rs +++ b/2015/rs/code/five/src/main.rs @@ -1,4 +1,4 @@ -static INPUT: &'static str = include_str!("input.txt"); +static INPUT: &str = include_str!("input.txt"); fn main() { let valueified = INPUT.split('\n').filter(|s| !s.is_empty()); @@ -34,7 +34,7 @@ fn main() { let mut flag2 = false; for c in s { - if !flag1 && (lc != c || (lc == c && (llc != lc || !pushed))) && dupeslist.contains(&(lc, c)) { flag1 = true; } + if !flag1 && (!pushed || llc != lc || lc != c) && dupeslist.contains(&(lc, c)) { flag1 = true; } if !flag1 && !dupeslist.contains(&(lc, c)) { dupeslist.push((lc, c)); pushed = true; } else { pushed = false; } if c == llc { flag2 = true; } diff --git a/2015/rs/code/four/src/main.rs b/2015/rs/code/four/src/main.rs index 0888816..a7d2842 100644 --- a/2015/rs/code/four/src/main.rs +++ b/2015/rs/code/four/src/main.rs @@ -2,7 +2,7 @@ use md5::{Digest, Md5}; use std::fmt::Write; use std::io::Write as WriteI; -static INPUT: &'static [u8] = b"yzbqklnj"; +static INPUT: &[u8] = b"yzbqklnj"; fn main() { let mut buf = Vec::with_capacity(INPUT.len() + 10); diff --git a/2015/rs/code/nine/src/main.rs b/2015/rs/code/nine/src/main.rs index 408b66a..1370354 100644 --- a/2015/rs/code/nine/src/main.rs +++ b/2015/rs/code/nine/src/main.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; -static INPUT: &'static str = include_str!("input.txt"); +static INPUT: &str = include_str!("input.txt"); fn main() { let valueified = INPUT.split('\n').filter(|s| !s.is_empty()) @@ -39,14 +39,13 @@ fn walk_steps(path: &mut Vec<&'static str>, dist: usize, bestpath: &mut Vec<&'st walk_steps(path, dist + stepdist, bestpath, bestdist, worstpath, worstdist, steps); path.pop(); } - } else { - if dist < *bestdist { - *bestpath = path.clone(); - *bestdist = dist; - } - else if dist > *worstdist { - *worstpath = path.clone(); - *worstdist = dist; - } + } + + else if dist < *bestdist { + *bestpath = path.clone(); + *bestdist = dist; + } else if dist > *worstdist { + *worstpath = path.clone(); + *worstdist = dist; } } diff --git a/2015/rs/code/one/src/main.rs b/2015/rs/code/one/src/main.rs index d9e16e1..131cf87 100644 --- a/2015/rs/code/one/src/main.rs +++ b/2015/rs/code/one/src/main.rs @@ -1,4 +1,4 @@ -static INPUT: &'static str = include_str!("input.txt"); +static INPUT: &str = include_str!("input.txt"); fn main() { let valueified = INPUT.chars().map(|c| match c { '(' => 1, ')' => -1, _ => 0}); diff --git a/2015/rs/code/six/src/main.rs b/2015/rs/code/six/src/main.rs index 6342cd9..679b561 100644 --- a/2015/rs/code/six/src/main.rs +++ b/2015/rs/code/six/src/main.rs @@ -1,4 +1,4 @@ -static INPUT: &'static str = include_str!("input.txt"); +static INPUT: &str = include_str!("input.txt"); #[derive(Debug)] enum LightCommand { diff --git a/2015/rs/code/three/src/main.rs b/2015/rs/code/three/src/main.rs index 770fc10..4e7d083 100644 --- a/2015/rs/code/three/src/main.rs +++ b/2015/rs/code/three/src/main.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; -static INPUT: &'static str = include_str!("input.txt"); +static INPUT: &str = include_str!("input.txt"); fn main() { let valueified = INPUT.chars().map(|c| match c { '<' => (-1, 0), '>' => (1, 0), '^' => (0, 1), 'v' => (0, -1), _ => (0, 0) }); diff --git a/2015/rs/code/two/src/main.rs b/2015/rs/code/two/src/main.rs index 2185bae..e01944a 100644 --- a/2015/rs/code/two/src/main.rs +++ b/2015/rs/code/two/src/main.rs @@ -1,4 +1,4 @@ -static INPUT: &'static str = include_str!("input.txt"); +static INPUT: &str = include_str!("input.txt"); fn main() { let valueified = INPUT |