My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code python
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update 2023/03

Simplify parsing by treating the '\n' as a non-digit char.

+3 -7
+3 -7
2023/day03.py
··· 6 6 # Parse input. 7 7 for y, line in enumerate(fileinput.input()): 8 8 num = '' 9 - start = None 10 - for x, c in enumerate(line.strip()): 11 - if not c.isdigit() and c != '.': 9 + for x, c in enumerate(line): 10 + if not c.isdigit() and c != '.' and c != '\n': 12 11 SYMBOLS[x, y] = c 13 12 14 13 if c.isdigit(): ··· 16 15 start = x 17 16 num += c 18 17 elif num: 19 - PARTS.append((int(num), y, start, x - 1)) 18 + PARTS.append((int(num), y, x - len(num), x - 1)) 20 19 num = '' 21 - 22 - if num: 23 - PARTS.append((int(num), y, start, x - 1)) 24 20 25 21 # Solve problem. 26 22 part_1_seen = set()