clippy changes
This commit is contained in:
parent
1f011f9826
commit
8f7fc726bc
@ -10,7 +10,7 @@ fn read_input() -> Vec<usize> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn part1(input: &Vec<usize>) -> usize {
|
||||
fn part1(input: &[usize]) -> usize {
|
||||
input
|
||||
.iter()
|
||||
.tuple_combinations()
|
||||
@ -18,7 +18,7 @@ fn part1(input: &Vec<usize>) -> usize {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn part2(input: &Vec<usize>) -> usize {
|
||||
fn part2(input: &[usize]) -> usize {
|
||||
let mut p2_table = [None; 2020];
|
||||
for (&a, &b) in input.iter().tuple_combinations() {
|
||||
if a + b < 2020 {
|
||||
@ -26,7 +26,7 @@ fn part2(input: &Vec<usize>) -> usize {
|
||||
}
|
||||
}
|
||||
let (a, b) = input.iter().find_map(|x| p2_table[2020 - x]).unwrap();
|
||||
return a * b * (2020 - a - b);
|
||||
a * b * (2020 - a - b)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -53,6 +53,7 @@ fn main() {
|
||||
println!("{}", p2);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
|
@ -14,8 +14,8 @@ type Forest = Vec<Vec<Tile>>;
|
||||
|
||||
const STEP_RIGHT: [usize; 5] = [1, 3, 5, 7, 1];
|
||||
const STEP_DOWN: [usize; 5] = [1, 1, 1, 1, 2];
|
||||
const TREE: u8 = '#' as u8;
|
||||
const FREE: u8 = '.' as u8;
|
||||
const TREE: u8 = b'#';
|
||||
const FREE: u8 = b'.';
|
||||
|
||||
impl From<u8> for Tile {
|
||||
#[inline]
|
||||
@ -95,7 +95,7 @@ mod tests {
|
||||
// branch-free version of if x >= width { x -= width }
|
||||
x -= width * ((x >= width) as usize);
|
||||
}
|
||||
return trees;
|
||||
trees
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -51,7 +51,7 @@ lazy_static! {
|
||||
static ref PID_REGEX: Regex = Regex::new(r"^\d{9}$").unwrap();
|
||||
}
|
||||
|
||||
fn part2(ps: &Vec<Passport>) -> usize {
|
||||
fn part2(ps: &[Passport]) -> usize {
|
||||
ps.iter()
|
||||
.filter(|p| {
|
||||
p.byr >= 1920
|
||||
|
Loading…
Reference in New Issue
Block a user