Function aoc::y15d11::y15d11

source ·
pub fn y15d11(input: &str, howmany: u32) -> String
Expand description

The solution for the day eleven challenge.

We take the input as a string and a second parameter for how many valid new passwords we want to generate (it just so happens that in part one it’s 1 and in part two it’s 2). We first convert the password into a vector of integers corresponding to the character code points. Then for the number of new passwords that we want we generate the next password and then until we have a valid password we keep generating the next password. Then we convert our vector back into a string and we’re done.

§Example

// probably read this from the input file...
let input = "zzzzzzzz";
assert_eq!(y15d11(input, 1), "aaaaaabcc");