use std::fs; use std::io::{self, Read}; fn solver(bytes: &Vec, marker_len: u32) -> u32 { let mut count = marker_len; for view in bytes.windows(marker_len as usize) { let mut acc: u32 = 0; for elt in view { acc |= 1 << (elt - 96); } if u32::count_ones(acc) >= marker_len { break; } count += 1; } count } fn main() -> io::Result<()> { let mut file = fs::File::open("input").unwrap(); let mut bytes: Vec = Vec::new(); file.read_to_end(&mut bytes)?; println!("All test passed. {}", solver(&bytes, 4)); println!("All test passed. {}", solver(&bytes, 14)); Ok(()) }