Expand description
ยงKeypad Conundrum
Each key sequence always end in A
. This means that we can consider each group of button
presses between A
s independently using a recursive approach with memoization to efficiently
compute the minimum presses needed for any depth of chained robots.
Functionsยง
- chain ๐
- dfs ๐
- pad_
combinations ๐Compute keypresses needed for all possible transitions for both numeric and directional keypads. There are no distinct pairs shared between the keypads so they can use the same map without conflict. - pad_
routes ๐Each route between two keys has 2 possibilites, horizontal first or vertical first. We skip any route that would cross the gap and also avoid adding the same route twice when a key is in a straight line (e.g. directly above/below or left/right). For example: - Convert codes to pairs of the sequence itself with the numeric part. The pad combinations are the same between both parts so only need to be computed once.
Type Aliasesยง
- Cache ๐
- Combinations ๐
- Input ๐