use std::{collections::BTreeSet, fs}; fn main() -> Result<(), Box> { let input = fs::read_to_string("inputs/day_6.txt")?; let chars: Vec = input.trim().chars().collect(); dbg!(find_distinct_char_run(&chars, 4)); dbg!(find_distinct_char_run(&chars, 14)); Ok(()) } fn find_distinct_char_run(chars: &[char], window_size: usize) -> Option { for (i, char_window) in chars.windows(window_size).enumerate() { let set: BTreeSet<&char> = char_window.iter().collect(); if set.len() == window_size { return Some(i + window_size); } } return None; }