|
@ -31,13 +31,13 @@ class Heightmap: |
|
|
elif y != max_y and self.heightmap[y+1][x] <= value: |
|
|
elif y != max_y and self.heightmap[y+1][x] <= value: |
|
|
continue |
|
|
continue |
|
|
|
|
|
|
|
|
self.low_point_values.append(value) |
|
|
|
|
|
|
|
|
self.low_point_values.append((x,y)) |
|
|
|
|
|
|
|
|
def calculate_risk_score(self): |
|
|
def calculate_risk_score(self): |
|
|
if self.low_point_values is None: |
|
|
if self.low_point_values is None: |
|
|
self.find_low_points() |
|
|
self.find_low_points() |
|
|
|
|
|
|
|
|
return sum(value+1 for value in self.low_point_values) |
|
|
|
|
|
|
|
|
return sum(self.heightmap[coords[1]][coords[0]]+1 for coords in self.low_point_values) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def part1(inputs: List[int]) -> int: |
|
|
def part1(inputs: List[int]) -> int: |
|
|