summary refs log tree commit diff
diff options
context:
space:
mode:
authordzwdz2022-12-08 17:36:30 +0100
committerdzwdz2022-12-08 17:36:30 +0100
commit4db98be450d917a9373fedb11292dd60fd81fb01 (patch)
tree2dcb79b095f2450556d07927594621859423efac
parent9860ed3a105e8eddeb9b6975ae919318cc57b2f8 (diff)
day 8 part 2
-rw-r--r--22.8/main.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/22.8/main.py b/22.8/main.py
index 624b890..78e67e4 100644
--- a/22.8/main.py
+++ b/22.8/main.py
@@ -4,7 +4,7 @@ def rot(a):
 	return [list(t) for t in zip(*a[::-1])]
 
 def flatten(a):
-	return sum(vis, [])
+	return sum(a, [])
 
 grid = [[int(c) for c in line.strip()] for line in stdin]
 vis = [[0 for _ in a] for a in grid]
@@ -20,3 +20,16 @@ for _ in range(4):
 	vis = rot(vis)
 
 print(len([c for c in flatten(vis) if c > 0]))
+
+scores = [[1 for _ in a] for a in grid]
+for _ in range(4):
+	for trees, to in zip(grid, scores):
+		lastBlock = [0] * 10
+		for i in range(len(trees)):
+			h = trees[i]
+			to[i] *= i - lastBlock[h]
+			for j in range(h + 1):
+				lastBlock[j] = i
+	grid = rot(grid)
+	scores = rot(scores)
+print(max(flatten(scores)))