File tree Expand file tree Collapse file tree 4 files changed +7
-4
lines changed Expand file tree Collapse file tree 4 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ macro_rules! run {
7373 wrapper: |data: & str | {
7474 use aoc:: $year:: $day:: * ;
7575
76- let input = parse( & data) ;
76+ let input = parse( data) ;
7777 let part1 = part1( & input) . to_string( ) ;
7878 let part2 = part2( & input) . to_string( ) ;
7979
Original file line number Diff line number Diff line change 22//!
33//! These codes allow command line applications to show colored or styled text in most terminals.
44//! Advanced commands can move the cursor or clear the screen.
5-
65pub const RESET : & str = "\x1b [0m" ;
76pub const BOLD : & str = "\x1b [1m" ;
87pub const RED : & str = "\x1b [31m" ;
Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff line change @@ -99,7 +99,11 @@ pub fn parse(input: &str) -> Input<'_> {
9999}
100100
101101pub 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
105109pub fn part2 ( input : & Input < ' _ > ) -> String {
You can’t perform that action at this time.
0 commit comments