Skip to content

Commit

Permalink
Use math.inf instead of large number
Browse files Browse the repository at this point in the history
  • Loading branch information
loociano committed Dec 28, 2024
1 parent 6253a42 commit 44a62be
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aoc2024/src/day21/python/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from math import inf
from typing import Sequence
from collections import deque, defaultdict
from itertools import product
Expand Down Expand Up @@ -103,7 +104,7 @@ def _calculate_paths_between_directional_keys() -> dict[(str, str), list[Path]]:
def _shortest_sequence_length(start_key: str, end_key: str, num_dir_keypads: int, remaining_dir_keypads: int) -> int:
if remaining_dir_keypads == 0:
return len(_DIR_KEYPAD_PATHS.get((start_key, end_key))[0]) # All shortest path(s) have same length.
min_button_presses = 1000000000000000
min_button_presses = inf
key_paths = _NUMPAD_PATHS if remaining_dir_keypads == num_dir_keypads else _DIR_KEYPAD_PATHS
for key_pair_path in key_paths.get((start_key, end_key)):
button_presses = 0
Expand Down

0 comments on commit 44a62be

Please sign in to comment.