Skip to content

Commit 3b03eb7

Browse files
committed
Tidy
1 parent f4e5f5b commit 3b03eb7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/year2019/day11.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn part2(input: &[i64]) -> String {
1919
let hull = paint(input, 1);
2020

2121
// Filter only white panels
22-
let panels: Vec<_> = hull.iter().filter(|&(_, &v)| v == 1).map(|(&k, _)| k).collect();
22+
let panels: Vec<_> = hull.iter().filter_map(|(&k, &v)| (v == 1).then_some(k)).collect();
2323

2424
// Get maximum extents
2525
let (x1, x2, y1, y2) = panels.iter().fold(

src/year2020/day21.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ pub fn parse(input: &str) -> Input<'_> {
9999
}
100100

101101
pub fn part1(input: &Input<'_>) -> u32 {
102-
input.ingredients.values().filter(|i| i.candidates == 0).map(|i| i.food.count_ones()).sum()
102+
input
103+
.ingredients
104+
.values()
105+
.filter_map(|i| (i.candidates == 0).then_some(i.food.count_ones()))
106+
.sum()
103107
}
104108

105109
pub fn part2(input: &Input<'_>) -> String {

0 commit comments

Comments
 (0)