Expand description
ยงCorporate Policy
Like the previous day we rely on the special structure of the input to solve more efficiently than the general case.
The key observation is that if there are no straights or pairs in the first 4 digits then the
next lowest valid sequence will end in a string of the form aabcc
,
compressing 2 pairs and a straight into 5 digits.
- If the current string ends with
xxyzz
then increment the third digit and wrap around toaabcc
. - The 5 digit sequence cannot start with any letter from
g
too
inclusive or it would contain an invalid character somewhere in the sequence.
Functionsยง
- clean ๐Sanitize the input to make sure it has no invalid characters. We increment the first invalid character found, for example
abcixyz
becomesabcjaaa
. - fill ๐Creates a sequence of form
aabcc
from an arbitrary starting character. - next_
password ๐Find the next valid 5 digit sequence of formaabcc
.