24 lines
600 B
Rust
24 lines
600 B
Rust
|
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
|
||
|
}
|