30 lines
588 B
Rust
30 lines
588 B
Rust
|
#![warn(clippy::pedantic)]
|
||
|
|
||
|
use std::{
|
||
|
collections::HashSet,
|
||
|
io::{stdin, Read},
|
||
|
};
|
||
|
|
||
|
use aoc::*;
|
||
|
|
||
|
fn main() {
|
||
|
let mut data = String::new();
|
||
|
stdin().read_to_string(&mut data).unwrap();
|
||
|
|
||
|
let i = data
|
||
|
.as_bytes()
|
||
|
.windows(4)
|
||
|
.position(|cs| HashSet::<u8>::from_iter(cs.into_iter().copied()).len() == 4)
|
||
|
.unwrap();
|
||
|
|
||
|
println!("{:?}", i + 4);
|
||
|
|
||
|
let i = data
|
||
|
.as_bytes()
|
||
|
.windows(14)
|
||
|
.position(|cs| HashSet::<u8>::from_iter(cs.into_iter().copied()).len() == 14)
|
||
|
.unwrap();
|
||
|
|
||
|
println!("{:?}", i + 14);
|
||
|
}
|