diff --git a/src/bin/day14.rs b/src/bin/day14.rs index bc071fa..41cbe1a 100644 --- a/src/bin/day14.rs +++ b/src/bin/day14.rs @@ -74,7 +74,7 @@ fn main() -> Result<(), Box> { let file = File::open("inputs/day14.txt")?; let mut lines = io::BufReader::new(file).lines(); - let mut polymer_template: Vec = lines.next().unwrap().unwrap().chars().collect(); + let polymer_template: Vec = lines.next().unwrap().unwrap().chars().collect(); lines.next(); let mut rules: HashMap<(char, char), char> = HashMap::new(); diff --git a/src/bin/day16.rs b/src/bin/day16.rs index 062bcec..2663aa7 100644 --- a/src/bin/day16.rs +++ b/src/bin/day16.rs @@ -1,7 +1,3 @@ -use std::cmp::Ordering; -use std::collections::BinaryHeap; -use std::collections::HashMap; -use std::collections::HashSet; use std::error::Error; use std::fs::File; use std::io::{self, BufRead}; diff --git a/src/bin/day17.rs b/src/bin/day17.rs index f8cac26..f125e97 100644 --- a/src/bin/day17.rs +++ b/src/bin/day17.rs @@ -1,11 +1,6 @@ -use std::cmp::Ordering; -use std::collections::BinaryHeap; -use std::collections::HashMap; -use std::collections::HashSet; use std::error::Error; use std::fs::File; use std::io::{self, BufRead}; -use std::vec::Vec; #[macro_use] extern crate lazy_static; @@ -35,7 +30,11 @@ fn is_hit( } if vx != 0 { - vx -= 1; + if vx > 0 { + vx -= 1; + } else { + vx += 1; + } } vy -= 1; @@ -90,7 +89,7 @@ fn main() -> Result<(), Box> { let mut hits = 0; - for vx in -256..256 { + for vx in 0..256 { for vy in -256..246 { let (hit, local_max_y) = is_hit(vx, vy, target.0, target.1, target.2, target.3); if hit {