Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pprint
- def get_puzzle_input(a_file_name: str) -> list[list[str]]:
- with open(a_file_name) as INFILE:
- return [[x for x in line.rstrip()] for line in INFILE if not line.startswith('!')]
- def get_grid(a_puzzle_input: list[list[str]]) -> list[list[str]]:
- return \
- [['#'] + (['#'] * len(a_puzzle_input[0])) + ['#']] + \
- [['#'] + line + ['#'] for line in a_puzzle_input] + \
- [['#'] + (['#'] * len(a_puzzle_input[0])) + ['#']]
- def get_start(a_grid: list[list[str]]) -> tuple[int, int]:
- for row in range(len(grid)):
- for col in range(len(grid[0])):
- if grid[row][col] == 'S':
- return row, col
- assert False, 'How did I get here?'
- return -1, -1
- puzzle_input = get_puzzle_input('advent_of_code_2023_day_21.txt')
- grid = get_grid(puzzle_input)
- pprint.pprint(grid)
- row, col = get_start(grid)
- print(f'{row}, {col}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement