Created
December 22, 2025 23:24
-
-
Save icub3d/a78eb3ef7df5bb1051e5d9446c7a02b8 to your computer and use it in GitHub Desktop.
Solution for Flip Flop 2025 Day 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::time::Instant; | |
| const INPUT: &str = include_str!("inputs/01.txt"); | |
| fn parse(input: &str) -> impl Iterator<Item = &str> { | |
| input.trim().lines() | |
| } | |
| fn p1(input: &str) -> usize { | |
| parse(input).map(|l| l.len() / 2).sum() | |
| } | |
| fn p2(input: &str) -> usize { | |
| parse(input) | |
| .map(|l| l.len() / 2) | |
| .filter(|l| l.is_multiple_of(2)) | |
| .sum() | |
| } | |
| fn p3(input: &str) -> usize { | |
| parse(input) | |
| .filter(|l| !l.contains('e')) | |
| .map(|l| l.len() / 2) | |
| .sum() | |
| } | |
| fn main() { | |
| let now = Instant::now(); | |
| let solution = p1(INPUT); | |
| println!("p1 {:?} {}", now.elapsed(), solution); | |
| let now = Instant::now(); | |
| let solution = p2(INPUT); | |
| println!("p2 {:?} {}", now.elapsed(), solution); | |
| let now = Instant::now(); | |
| let solution = p3(INPUT); | |
| println!("p3 {:?} {}", now.elapsed(), solution); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment