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