Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save icub3d/a0fab19a16a68065b2fad30158f8aa4e to your computer and use it in GitHub Desktop.
Solution for Flip Flop 2025 Day 2
use std::time::Instant;
const INPUT: &str = include_str!("inputs/day02.txt");
fn parse(input: &str) -> impl Iterator<Item = &str> {
// TODO did you trim today?
input.trim().lines()
}
fn p1(input: &str) -> usize {
let input = parse(input);
input.count()
}
fn p2(input: &str) -> usize {
let input = parse(input);
input.count()
}
fn p3(input: &str) -> usize {
let input = parse(input);
input.count()
}
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);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_p1() {
let input = "123\n456\n789\n";
assert_eq!(p1(input), 3);
}
#[test]
fn test_p2() {
let input = "123\n456\n789\n";
assert_eq!(p2(input), 3);
}
#[test]
fn test_p3() {
let input = "123\n456\n789\n";
assert_eq!(p3(input), 3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment