Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5cfe7ad

Browse files
committed
Update 9-2.py
1 parent 38c66c0 commit 5cfe7ad

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Day 9/9-2.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Import input from file as a list
2-
source = open('input.txt').readlines()
2+
source = open('example_input.txt').readlines()
33

44
#Remove linebreaks from list
55
for i in range(len(source)):
@@ -49,11 +49,11 @@
4949
low = False
5050
#Check if it is a low point
5151
if low == True:
52-
low_points.append(heightmap[row][value])
52+
low_points.append(row)
53+
low_points.append(value)
54+
#low_points is now a list of integers that form the coordinates of all the low points
5355

54-
#Add one to each point and sum
55-
for i in range(len(low_points)):
56-
low_points[i] += 1
56+
for low_point in range(0, len(low_points), 2):
57+
5758

58-
#Result = 539
59-
print(sum(low_points))
59+
#Check a cell, if there is no 9, check that cell, keep going until you have no cells to check

0 commit comments

Comments
 (0)