Skip to content

Instantly share code, notes, and snippets.

@icub3d
Created December 22, 2025 23:24
Show Gist options
  • Select an option

  • Save icub3d/a78eb3ef7df5bb1051e5d9446c7a02b8 to your computer and use it in GitHub Desktop.

Select an option

Save icub3d/a78eb3ef7df5bb1051e5d9446c7a02b8 to your computer and use it in GitHub Desktop.
Solution for Flip Flop 2025 Day 1
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