-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (40 loc) · 1.04 KB
/
main.py
File metadata and controls
52 lines (40 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# --- Day 8: Treetop Tree House ---
from pprint import pprint
test = """30373
25512
65332
33549
35390
"""
lines = [list(x) for x in test.split("\n")]
# create grid
grid = [list(map(int, row)) for row in test.split()]
pprint(grid)
rows, cols = len(grid), len(grid[0])
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
def travel(r, c, dr, dc):
while 0 <= (r := r + dr) < rows and 0 <= (c := c + dc) < cols:
yield grid[r][c]
# tree_can_be_visible()
# print(list(travel(0,0,0,1)))
# print(list(travel(0,0,1,1)))
# print(list(travel(0,0,1,0)))
visible = []
edges = 4 * (len(lines) - 1) # 16
# visible = (len(trees) - 1) * 4
# count_visibles = edges
# for line in lines:
# # data = re.findall('\\d', line)
# # print(data)
#
# # just inner trees to pick up
# for item in line:
# print(f"{item}")
#
# for i in range(-1, 2):
# for j in range(-1, 2):
# # print((i, j))
# if item > lines[i][j]:
# visible.append(item)
# print('----')
# print(count_visibles)