summaryrefslogtreecommitdiff
path: root/2024/07/python/main.py
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2025-09-12 20:20:58 +0100
committermhsn <mail@mhsn.net>2025-09-12 20:36:09 +0100
commit6b733982f9f240c1c97f1fa705bfbe4cd93c640e (patch)
treedad623203c8bb40f372e0ea14479c2f564efda79 /2024/07/python/main.py
parent9299c4ef655b88eb8b571864c939c78b27f77723 (diff)
downloadaoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.tar.gz
aoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.zip
simplify python file structure
Diffstat (limited to '2024/07/python/main.py')
-rw-r--r--2024/07/python/main.py35
1 files changed, 0 insertions, 35 deletions
diff --git a/2024/07/python/main.py b/2024/07/python/main.py
deleted file mode 100644
index 0e72772..0000000
--- a/2024/07/python/main.py
+++ /dev/null
@@ -1,35 +0,0 @@
-from fileinput import input
-
-lines = [line.strip() for line in input()]
-
-
-def solve(w, acc, rest, gold=False):
- if not rest:
- return w == acc
- if w < acc:
- return False
- head, *rest = rest
- return (
- solve(w, acc + head, rest, gold)
- or solve(w, acc * head, rest, gold)
- or (gold and solve(w, int(str(acc) + str(head)), rest, gold))
- )
-
-
-silver = 0
-gold = 0
-
-for line in lines:
- want, nums = line.split(":")
- want = int(want)
- nums = [int(n) for n in nums.split()]
- head, *rest = nums
-
- if solve(want, head, rest):
- silver += want
- if solve(want, head, rest, True):
- gold += want
-
-
-print("silver:", silver)
-print("gold:", gold)