From a9ab1f136aad824fb57f374f381e6b1986cdc42a Mon Sep 17 00:00:00 2001 From: mhsn Date: Tue, 23 Dec 2025 18:47:31 +0000 Subject: 25-07 python p1 --- 2025/07/python.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 2025/07/python.py (limited to '2025/07/python.py') diff --git a/2025/07/python.py b/2025/07/python.py new file mode 100755 index 0000000..48a8f2a --- /dev/null +++ b/2025/07/python.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +from fileinput import input +from functools import partial, reduce + +lines = [line.strip() for line in input()] + +bs = {lines[0].index("S")} +silver = 0 + + +def split(t: int, c: int) -> set[int]: + global silver + if lines[t][c] == "^": + silver += 1 + return {c - 1, c + 1} + return {c} + + +for t, _ in enumerate(lines): + bs = reduce(set.union, map(partial(split, t), bs)) + + +gold = 0 + +print("silver:", silver) +print("gold:", gold) -- cgit v1.2.3