|
|
|
|
|
|
|
|
lines = load_input(3) |
|
|
lines = load_input(3) |
|
|
# Input is lines of periods (.), numbers (0-9), and symbols |
|
|
# Input is lines of periods (.), numbers (0-9), and symbols |
|
|
# (anything that isn't a period or number) |
|
|
# (anything that isn't a period or number) |
|
|
# Any number adjacent (horizontally, vertically, diagonally) |
|
|
|
|
|
# to a symbol is a part number. Get the sum of the part numbers. |
|
|
|
|
|
|
|
|
# Any asterisk (*) adjacent to exactly two numbers is a gear; |
|
|
|
|
|
# its value is the product of the two numbers. |
|
|
|
|
|
# Get the sum of all of the gear values. |
|
|
max_len = len(lines[0]) # all lines are the same length |
|
|
max_len = len(lines[0]) # all lines are the same length |
|
|
for j, line in enumerate(lines): |
|
|
for j, line in enumerate(lines): |
|
|
i = 0 |
|
|
i = 0 |