extern crate queue; use std::collections::HashSet; use queue::Queue; fn main() { const INPUT: &str = include_str!("../sample_input.txt"); let mut buf: Queue = Queue::with_capacity(4); let mut msg_buf: Queue = Queue::with_capacity(14); let mut found_start = false; for (i, c) in INPUT.chars().enumerate() { if buf.force_queue(c) == 4 && !found_start { let x = HashSet::<&char>::from_iter(buf.vec().iter()).len(); if x == 4 { println!("{} {:?}", i + 1, buf); found_start = true; } } if msg_buf.force_queue(c) == 14 { let x = HashSet::<&char>::from_iter(msg_buf.vec().iter()).len(); if x == 14 { println!("{} {:?}", i + 1, msg_buf); break; } } } }