Linter cleanups

This commit is contained in:
Sebastian 2021-12-17 14:25:34 +01:00
parent a2b4066618
commit f4c64f39c4
3 changed files with 7 additions and 12 deletions

View File

@ -74,7 +74,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let file = File::open("inputs/day14.txt")?; let file = File::open("inputs/day14.txt")?;
let mut lines = io::BufReader::new(file).lines(); let mut lines = io::BufReader::new(file).lines();
let mut polymer_template: Vec<char> = lines.next().unwrap().unwrap().chars().collect(); let polymer_template: Vec<char> = lines.next().unwrap().unwrap().chars().collect();
lines.next(); lines.next();
let mut rules: HashMap<(char, char), char> = HashMap::new(); let mut rules: HashMap<(char, char), char> = HashMap::new();

View File

@ -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::error::Error;
use std::fs::File; use std::fs::File;
use std::io::{self, BufRead}; use std::io::{self, BufRead};

View File

@ -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::error::Error;
use std::fs::File; use std::fs::File;
use std::io::{self, BufRead}; use std::io::{self, BufRead};
use std::vec::Vec;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
@ -35,7 +30,11 @@ fn is_hit(
} }
if vx != 0 { if vx != 0 {
vx -= 1; if vx > 0 {
vx -= 1;
} else {
vx += 1;
}
} }
vy -= 1; vy -= 1;
@ -90,7 +89,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut hits = 0; let mut hits = 0;
for vx in -256..256 { for vx in 0..256 {
for vy in -256..246 { for vy in -256..246 {
let (hit, local_max_y) = is_hit(vx, vy, target.0, target.1, target.2, target.3); let (hit, local_max_y) = is_hit(vx, vy, target.0, target.1, target.2, target.3);
if hit { if hit {