Skip to content

Commit

Permalink
solved day 9 part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Wilson committed Dec 9, 2021
1 parent 663fe31 commit 80e73f1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 9/9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
heightmap = []
sumoflowpoints = 0

while True:
newline = input()
if newline == '':
break
intmap = map(int, newline)
heightmap.append(list(intmap))

for y in range(len(heightmap)):
for x in range(len(heightmap[0])):
placefound = True
if x > 0:
if heightmap[y][x] >= heightmap[y][x-1]:
placefound = False
if x < len(heightmap[y])-1:
if heightmap[y][x] >= heightmap[y][x+1]:
placefound = False
if y > 0:
if heightmap[y][x] >= heightmap[y-1][x]:
placefound = False
if y < len(heightmap)-1:
if heightmap[y][x] >= heightmap[y+1][x]:
placefound = False
if placefound:
print (str(x)+","+str(y)+" = "+str(heightmap[y][x]))
sumoflowpoints = sumoflowpoints + 1 + heightmap[y][x]

print(str(sumoflowpoints))

0 comments on commit 80e73f1

Please sign in to comment.