day6.rs (576B)
1 pub fn run(input: String) { 2 //let wlen = 4; 3 let wlen = 14; 4 let (wix, _) = input.chars().collect::<Vec<char>>().windows(wlen).enumerate().find(|(_, win)| { 5 //println!("checking window {:?}", win.into_iter().map(|ch|{ch.to_owned()}).collect::<Vec<char>>()); 6 let n = win.len(); 7 for i in 0..n { 8 for j in i..n { 9 if i != j && win[i]==win[j] { 10 return false; 11 } 12 } 13 } 14 return true; 15 }).expect("no unique sequence!"); 16 println!("Day 6: {}", wix + wlen); 17 }