aboutsummaryrefslogtreecommitdiff
path: root/2023/13
diff options
context:
space:
mode:
authorMarvin Borner2023-12-13 19:56:42 +0100
committerMarvin Borner2023-12-13 19:56:42 +0100
commitca4f6e6c45e9d3eab854309fa379de71289ab99c (patch)
tree9916f7a0111e60ec632a64838fb6ff4cd6bae7d0 /2023/13
parent3b65cf1b091f7b1959812f02db0cd07b1e6ca48e (diff)
six sigma black belt enterprise
Diffstat (limited to '2023/13')
-rw-r--r--2023/13/solve.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/2023/13/solve.py b/2023/13/solve.py
new file mode 100644
index 0000000..fc17d79
--- /dev/null
+++ b/2023/13/solve.py
@@ -0,0 +1,18 @@
+B = [l.splitlines() for l in open("input").read().strip().split("\n\n")]
+
+
+def solve(ls, delta):
+ for row in range(1, len(ls)):
+ errors = 0
+ for prev, next in zip(ls[:row][::-1], ls[row:]):
+ for p, n in zip(prev, next):
+ if p == n:
+ continue
+ errors += 1
+ if errors == delta:
+ return row
+ return 0
+
+
+print(sum(solve([*zip(*ls)], 0) + solve(ls, 0) * 100 for ls in B))
+print(sum(solve([*zip(*ls)], 1) + solve(ls, 1) * 100 for ls in B))