示例#1
0
def part_two(grid: Grid) -> int:
    low_points = [p for p, v in grid.search(mindepth)]
    sizes = []
    for lp in low_points:
        matches = list(grid.collect_recursive([lp], notnine))
        sizes.append(len(matches))
    top3 = sorted(sizes, reverse=True)[:3]
    return math.prod(top3)
示例#2
0
def part_one(grid: Grid) -> int:
    return sum(val + 1 for _, val in grid.search(mindepth))