done with day6 part1

This commit is contained in:
Joe Ardent 2022-12-06 16:30:35 -08:00
parent 96441ccdbd
commit 1c7913285c
2 changed files with 24 additions and 0 deletions

23
2022-aoc/src/d6.rs Normal file
View file

@ -0,0 +1,23 @@
use aoc_runner_derive::{aoc as aoc_run, aoc_generator};
use std::collections::HashSet;
type Beep = HashSet<char>;
#[aoc_generator(day6)]
fn parse_input_day1(input: &str) -> String {
input.to_string()
}
#[aoc_run(day6, part1)]
fn part1(input: &str) -> usize {
let input = input.trim();
let mut out = 4;
for (i, c) in input.as_bytes().windows(4).enumerate() {
let window = Beep::from_iter(c.iter().map(|c| *c as char));
out = i + 4;
dbg!(i, std::str::from_utf8(c).unwrap(), &window);
if window.len() == 4 {
break;
}
}
out
}

View file

@ -5,5 +5,6 @@ mod d2;
mod d3; mod d3;
mod d4; mod d4;
mod d5; mod d5;
mod d6;
aoc_lib! { year = 2022 } aoc_lib! { year = 2022 }