diff options
author | dzwdz | 2022-12-08 09:50:22 +0100 |
---|---|---|
committer | dzwdz | 2022-12-08 09:50:22 +0100 |
commit | 9860ed3a105e8eddeb9b6975ae919318cc57b2f8 (patch) | |
tree | edfa28e804ea52cb30e8e9c09023375194750f54 | |
parent | 0f971271ade8f7ca4706881809b2e8e367ad07d1 (diff) |
day 8 part 1 from a phone
-rw-r--r-- | 22.8/main.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/22.8/main.py b/22.8/main.py new file mode 100644 index 0000000..624b890 --- /dev/null +++ b/22.8/main.py @@ -0,0 +1,22 @@ +from sys import stdin + +def rot(a): + return [list(t) for t in zip(*a[::-1])] + +def flatten(a): + return sum(vis, []) + +grid = [[int(c) for c in line.strip()] for line in stdin] +vis = [[0 for _ in a] for a in grid] + +for _ in range(4): + for trees, to in zip(grid, vis): + highest = -1 + for i in range(len(trees)): + if highest < trees[i]: + highest = trees[i] + to[i] += 1 + grid = rot(grid) + vis = rot(vis) + +print(len([c for c in flatten(vis) if c > 0])) |