done with part 2

This commit is contained in:
Joe Ardent 2022-12-06 17:09:58 -08:00
parent 1c7913285c
commit d4af3e7c26

View file

@ -7,15 +7,23 @@ type Beep = HashSet<char>;
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() {
get_token(input.trim(), 4)
}
#[aoc_run(day6, part2)]
fn part2(input: &str) -> usize {
get_token(input.trim(), 14)
}
fn get_token(input: &str, len: usize) -> usize {
let mut out = 0;
for (i, c) in input.as_bytes().windows(len).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 {
out = i + len;
if window.len() == len {
break;
}
}