import os input = open(os.path.dirname(__file__) + "/input.txt", "r").readlines() trees = [] for l in input: l = l.strip() tmp = [] for x in l: tmp.append([int(x), False]) trees.append(tmp) height_ = len(trees) width = len(trees[0]) # for x in range(0, height_, 1): # print(trees[x]) for x in range(0, width, 1): height = 0 for y in range(0, width, 1): if trees[x][y][0] > height or (x == 0) or (y == 0) or (x == width-1) or (y == height_-1): trees[x][y][1] = True height = trees[x][y][0] height = 0 for y in range(width-1, -1, -1): if trees[x][y][0] > height or (x == 0) or (y == 0) or (x == width-1) or (y == height_-1): trees[x][y][1] = True height = trees[x][y][0] for y in range(0, height_, 1): height = 0 for x in range(0, height_, 1): if trees[x][y][0] > height or (x == 0) or (y == 0) or (x == width-1) or (y == height_-1): trees[x][y][1] = True height = trees[x][y][0] height = 0 for x in range(height_-1, -1, -1): if trees[x][y][0] > height or (x == 0) or (y == 0) or (x == width-1) or (y == height_-1): trees[x][y][1] = True height = trees[x][y][0] tot = 0 for x in range(0, height_, 1): # print(trees[x]) for y in range(0, width, 1): if trees[x][y][1]: tot += 1 print(tot)