decided to clippy 2023 in 2024
This commit is contained in:
@@ -23,13 +23,13 @@ impl Drawing {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|mound| mound.x + span >= reflect_col && mound.x < reflect_col)
|
.filter(|mound| mound.x + span >= reflect_col && mound.x < reflect_col)
|
||||||
.map(|mound| (2 * reflect_col - mound.x - 1, mound.y).into())
|
.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
|
&& self
|
||||||
.mounds
|
.mounds
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|mound| mound.x < reflect_col + span && mound.x >= reflect_col)
|
.filter(|mound| mound.x < reflect_col + span && mound.x >= reflect_col)
|
||||||
.map(|mound| (2 * reflect_col - mound.x - 1, mound.y).into())
|
.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>();
|
.sum::<u32>();
|
||||||
let row_score = (1..max_row)
|
let row_score = (1..max_row)
|
||||||
@@ -40,13 +40,13 @@ impl Drawing {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|mound| mound.y + span >= reflect_row && mound.y < reflect_row)
|
.filter(|mound| mound.y + span >= reflect_row && mound.y < reflect_row)
|
||||||
.map(|mound| (mound.x, 2 * reflect_row - mound.y - 1).into())
|
.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
|
&& self
|
||||||
.mounds
|
.mounds
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|mound| mound.y < reflect_row + span && mound.y >= reflect_row)
|
.filter(|mound| mound.y < reflect_row + span && mound.y >= reflect_row)
|
||||||
.map(|mound| (mound.x, 2 * reflect_row - mound.y - 1).into())
|
.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>()
|
.sum::<u32>()
|
||||||
* 100;
|
* 100;
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ impl Drawing {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|mound| mound.x + span >= reflect_col && mound.x < reflect_col)
|
.filter(|mound| mound.x + span >= reflect_col && mound.x < reflect_col)
|
||||||
.map(|mound| (2 * reflect_col - mound.x - 1, mound.y).into())
|
.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()
|
.count()
|
||||||
+ self
|
+ self
|
||||||
.mounds
|
.mounds
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|mound| mound.x < reflect_col + span && mound.x >= reflect_col)
|
.filter(|mound| mound.x < reflect_col + span && mound.x >= reflect_col)
|
||||||
.map(|mound| (2 * reflect_col - mound.x - 1, mound.y).into())
|
.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())
|
.count())
|
||||||
== 1
|
== 1
|
||||||
})
|
})
|
||||||
@@ -45,14 +45,14 @@ impl Drawing {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|mound| mound.y + span >= reflect_row && mound.y < reflect_row)
|
.filter(|mound| mound.y + span >= reflect_row && mound.y < reflect_row)
|
||||||
.map(|mound| (mound.x, 2 * reflect_row - mound.y - 1).into())
|
.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()
|
.count()
|
||||||
+ self
|
+ self
|
||||||
.mounds
|
.mounds
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|mound| mound.y < reflect_row + span && mound.y >= reflect_row)
|
.filter(|mound| mound.y < reflect_row + span && mound.y >= reflect_row)
|
||||||
.map(|mound| (mound.x, 2 * reflect_row - mound.y - 1).into())
|
.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())
|
.count())
|
||||||
== 1
|
== 1
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -57,11 +57,12 @@ pub fn part2(input: &str) -> String {
|
|||||||
|
|
||||||
let pos_in_cycle = start_of_cycle + (cycles - end_of_cycle) % len_of_cyle;
|
let pos_in_cycle = start_of_cycle + (cycles - end_of_cycle) % len_of_cyle;
|
||||||
|
|
||||||
map = cache
|
map.clone_from(
|
||||||
.values()
|
cache
|
||||||
.find_map(|(look_at_map, pos)| (*pos == pos_in_cycle).then_some(look_at_map))
|
.values()
|
||||||
.unwrap()
|
.find_map(|(look_at_map, pos)| (*pos == pos_in_cycle).then_some(look_at_map))
|
||||||
.clone();
|
.unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
let mut total = 0_usize;
|
let mut total = 0_usize;
|
||||||
for col in 0..maxes.x {
|
for col in 0..maxes.x {
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ pub fn part1(input: &str) -> String {
|
|||||||
.filter_map(|dir| {
|
.filter_map(|dir| {
|
||||||
let next_pos = dir + *pos;
|
let next_pos = dir + *pos;
|
||||||
node_map
|
node_map
|
||||||
.get(&next_pos)
|
.contains_key(&next_pos)
|
||||||
.is_some()
|
|
||||||
.then(|| (node_map[pos], node_map[&next_pos], 1))
|
.then(|| (node_map[pos], node_map[&next_pos], 1))
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ pub fn part2(input: &str) -> String {
|
|||||||
.filter_map(|dir| {
|
.filter_map(|dir| {
|
||||||
let next_pos = dir + *pos;
|
let next_pos = dir + *pos;
|
||||||
node_map
|
node_map
|
||||||
.get(&next_pos)
|
.contains_key(&next_pos)
|
||||||
.is_some()
|
|
||||||
.then(|| (node_map[pos], node_map[&next_pos], 1))
|
.then(|| (node_map[pos], node_map[&next_pos], 1))
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub fn part1(input: &str) -> String {
|
|||||||
.filter(|x| {
|
.filter(|x| {
|
||||||
x.generate_adjacent()
|
x.generate_adjacent()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|t| symbols.get(t).is_some())
|
.any(|t| symbols.contains_key(t))
|
||||||
})
|
})
|
||||||
.map(|x| x.no)
|
.map(|x| x.no)
|
||||||
.sum::<u64>()
|
.sum::<u64>()
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ impl ItemMap {
|
|||||||
.expect("always")
|
.expect("always")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// part1 of day 5 of AOC 2023
|
/// part1 of day 5 of AOC 2023
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -81,7 +82,6 @@ impl ItemMap {
|
|||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
/// panics whenever the input isn't parsable
|
/// panics whenever the input isn't parsable
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn part1(input: &str) -> String {
|
pub fn part1(input: &str) -> String {
|
||||||
let (_input, (mut to_process, maps)) = parse_input(input).expect("aoc always has input");
|
let (_input, (mut to_process, maps)) = parse_input(input).expect("aoc always has input");
|
||||||
|
|||||||
Reference in New Issue
Block a user