summaryrefslogtreecommitdiff
path: root/2025/day10.py
diff options
context:
space:
mode:
Diffstat (limited to '2025/day10.py')
-rwxr-xr-x2025/day10.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/2025/day10.py b/2025/day10.py
new file mode 100755
index 0000000..5eea131
--- /dev/null
+++ b/2025/day10.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python3
+from functools import reduce
+from re import findall
+from copy import deepcopy
+import sys
+from itertools import combinations
+import numpy as np
+from scipy.optimize import linprog
+
+filename = sys.argv[1] if len(sys.argv) == 2 \
+ else "in/" + sys.argv[0].split('/')[-1].rstrip(".py") + ".pzl"
+data = open(filename).read()
+lines = data.rstrip('\n').split('\n')
+
+res1 = 0
+res2 = 0
+
+def part1(light, buttons):
+ for r in range(len(buttons)):
+ for c in combinations(buttons, r):
+ state = [0 for _ in light]
+ for b in c:
+ for l in b:
+ state[l] ^= 1
+
+ if light == state:
+ return r
+
+for line in lines:
+ s = line.split(' ')
+ s_light = s[0]
+ s_buttons = s[1:-1]
+ s_jolt = s[-1]
+
+ light = [1 if i == '#' else 0 for i in s_light[1:-1]]
+
+ buttons = []
+ for sb in s_buttons:
+ buttons.append([int(i) for i in sb[1:-1].split(',')])
+
+ jolt = [int(i) for i in s_jolt[1:-1].split(',')]
+
+ res = part1(light, buttons)
+ res1 += res
+
+print('res1:', res1)
+print('res2:', res2)
+