decided to clippy 2023 in 2024

This commit is contained in:
Dylan Thies
2024-12-02 11:49:26 -05:00
parent 0e93372b96
commit cd22838062
7 changed files with 18 additions and 19 deletions

View File

@@ -23,13 +23,13 @@ impl Drawing {
.iter()
.filter(|mound| mound.x + span >= reflect_col && mound.x < reflect_col)
.map(|mound| (2 * reflect_col - mound.x - 1, mound.y).into())
.all(|mound_reflect| self.mounds.get(&mound_reflect).is_some())
.all(|mound_reflect| self.mounds.contains(&mound_reflect))
&& self
.mounds
.iter()
.filter(|mound| mound.x < reflect_col + span && mound.x >= reflect_col)
.map(|mound| (2 * reflect_col - mound.x - 1, mound.y).into())
.all(|mound_reflect| self.mounds.get(&mound_reflect).is_some())
.all(|mound_reflect| self.mounds.contains(&mound_reflect))
})
.sum::<u32>();
let row_score = (1..max_row)
@@ -40,13 +40,13 @@ impl Drawing {
.iter()
.filter(|mound| mound.y + span >= reflect_row && mound.y < reflect_row)
.map(|mound| (mound.x, 2 * reflect_row - mound.y - 1).into())
.all(|mound_reflect| self.mounds.get(&mound_reflect).is_some())
.all(|mound_reflect| self.mounds.contains(&mound_reflect))
&& self
.mounds
.iter()
.filter(|mound| mound.y < reflect_row + span && mound.y >= reflect_row)
.map(|mound| (mound.x, 2 * reflect_row - mound.y - 1).into())
.all(|mound_reflect| self.mounds.get(&mound_reflect).is_some())
.all(|mound_reflect| self.mounds.contains(&mound_reflect))
})
.sum::<u32>()
* 100;

View File

@@ -24,14 +24,14 @@ impl Drawing {
.iter()
.filter(|mound| mound.x + span >= reflect_col && mound.x < reflect_col)
.map(|mound| (2 * reflect_col - mound.x - 1, mound.y).into())
.filter(|mound_reflect| self.mounds.get(mound_reflect).is_none())
.filter(|mound_reflect| !self.mounds.contains(mound_reflect))
.count()
+ self
.mounds
.iter()
.filter(|mound| mound.x < reflect_col + span && mound.x >= reflect_col)
.map(|mound| (2 * reflect_col - mound.x - 1, mound.y).into())
.filter(|mound_reflect| self.mounds.get(mound_reflect).is_none())
.filter(|mound_reflect| !self.mounds.contains(mound_reflect))
.count())
== 1
})
@@ -45,14 +45,14 @@ impl Drawing {
.iter()
.filter(|mound| mound.y + span >= reflect_row && mound.y < reflect_row)
.map(|mound| (mound.x, 2 * reflect_row - mound.y - 1).into())
.filter(|mound_reflect| self.mounds.get(mound_reflect).is_none())
.filter(|mound_reflect| !self.mounds.contains(mound_reflect))
.count()
+ self
.mounds
.iter()
.filter(|mound| mound.y < reflect_row + span && mound.y >= reflect_row)
.map(|mound| (mound.x, 2 * reflect_row - mound.y - 1).into())
.filter(|mound_reflect| self.mounds.get(mound_reflect).is_none())
.filter(|mound_reflect| !self.mounds.contains(mound_reflect))
.count())
== 1
})

View File

@@ -57,11 +57,12 @@ pub fn part2(input: &str) -> String {
let pos_in_cycle = start_of_cycle + (cycles - end_of_cycle) % len_of_cyle;
map = cache
.values()
.find_map(|(look_at_map, pos)| (*pos == pos_in_cycle).then_some(look_at_map))
.unwrap()
.clone();
map.clone_from(
cache
.values()
.find_map(|(look_at_map, pos)| (*pos == pos_in_cycle).then_some(look_at_map))
.unwrap(),
);
let mut total = 0_usize;
for col in 0..maxes.x {

View File

@@ -60,8 +60,7 @@ pub fn part1(input: &str) -> String {
.filter_map(|dir| {
let next_pos = dir + *pos;
node_map
.get(&next_pos)
.is_some()
.contains_key(&next_pos)
.then(|| (node_map[pos], node_map[&next_pos], 1))
})
.collect::<Vec<_>>()

View File

@@ -47,8 +47,7 @@ pub fn part2(input: &str) -> String {
.filter_map(|dir| {
let next_pos = dir + *pos;
node_map
.get(&next_pos)
.is_some()
.contains_key(&next_pos)
.then(|| (node_map[pos], node_map[&next_pos], 1))
})
.collect::<Vec<_>>()

View File

@@ -34,7 +34,7 @@ pub fn part1(input: &str) -> String {
.filter(|x| {
x.generate_adjacent()
.iter()
.any(|t| symbols.get(t).is_some())
.any(|t| symbols.contains_key(t))
})
.map(|x| x.no)
.sum::<u64>()

View File

@@ -74,6 +74,7 @@ impl ItemMap {
.expect("always")
}
}
/// part1 of day 5 of AOC 2023
///
/// # Arguments
@@ -81,7 +82,6 @@ impl ItemMap {
///
/// # Panics
/// panics whenever the input isn't parsable
#[must_use]
pub fn part1(input: &str) -> String {
let (_input, (mut to_process, maps)) = parse_input(input).expect("aoc always has input");