From eb233235c876600bafa39a538d18ce11cfc72b39 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 7 Dec 2025 09:14:27 +0100 Subject: Clean up and alternative solution to day 7 --- 2025/07/b2.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 2025/07/b2.py (limited to '2025/07/b2.py') diff --git a/2025/07/b2.py b/2025/07/b2.py new file mode 100644 index 0000000..b77188c --- /dev/null +++ b/2025/07/b2.py @@ -0,0 +1,17 @@ +import fileinput + +with fileinput.input() as lines: + rows = [line[:-1] for line in lines] + +t = [1 if x == 'S' else 0 for x in rows[0]] +for row in rows[1:]: + next = [0] * len(row) + for i in range(len(row)): + if row[i] == '^': + next[i-1] += t[i] + next[i+1] += t[i] + else: + next[i] += t[i] + t = next + +print(sum(t)) -- cgit v1.3