1
0
Fork 0
AdvenOfCode2022/src/prob6.rs

18 lines
421 B
Rust
Raw Normal View History

2022-12-29 13:55:39 +01:00
use itertools::Itertools;
2022-12-29 13:55:39 +01:00
fn begin_datagram(datagram: &str, size: usize) -> usize {
size + datagram
.as_bytes()
.windows(size)
.position(|window| window.iter().tuple_combinations().all(|(a, b)| a != b))
.unwrap()
}
pub fn solve_part1(content: &str) -> i32 {
2022-12-29 13:55:39 +01:00
begin_datagram(content, 4) as i32
2022-12-27 14:11:29 +01:00
}
2022-12-29 13:55:59 +01:00
pub fn solve_part2(content: &str) -> i32 {
begin_datagram(content, 14) as i32
}