porting over AOC from previous years to a monorepo.
This commit is contained in:
commit
84c4cf9991
194 changed files with 30104 additions and 0 deletions
23
2022/days/06/src/part2.rs
Normal file
23
2022/days/06/src/part2.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use crate::utilities::*;
|
||||
|
||||
pub fn part2(input: &str) -> usize {
|
||||
input
|
||||
.as_bytes()
|
||||
.windows(14)
|
||||
.position(|x| !find_dupes_stupid(x))
|
||||
.unwrap()+14
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_part2() {
|
||||
assert_eq!(part2("mjqjpqmgbljsphdztnvjfqwrcgsmlb"), 19);
|
||||
assert_eq!(part2("bvwbjplbgvbhsrlpgdmjqwftvncz"), 23);
|
||||
assert_eq!(part2("nppdvjthqldpwncqszvftbrmjlhg"), 23);
|
||||
assert_eq!(part2("nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg"), 29);
|
||||
assert_eq!(part2("zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw"), 26);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue