pub fn y15d05(input: &str, part: u32) -> u32
Expand description
The solution for the day five challenge.
We expect the input as a string and either part 1
or part 2
to decide
which ruleset to use to determine “nice” strings.
In part one nice strings contain at least three vowels (aeiou
only),
contains at least one letter that appears twice in a row, and does not
contain any of these substrings: ab
, cd
, pq
, or xy
. The final rule
takes precedence over the first two, that is if a string meets the first
two criteria but has one of the forbidden substrings then it is still
naughty.
In part two the rules are slightly different. A nice string contains at least one pair of non-overlapping (in position in the string) characters and at least one character that repeats after one other character.
§Example
// probably read this from the input file...
let input = "abc\naeidd\nxxxxyx";
assert_eq!(y15d05(input, 1), 1);
assert_eq!(y15d05(input, 2), 1);