Skip to content

Commit 3ee0e96

Browse files
committed
New day
1 parent 6e46518 commit 3ee0e96

3 files changed

Lines changed: 70 additions & 8 deletions

File tree

aoc/2025/06/06.vn.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Advent of code Day 06
2+
# https://adventofcode.com/2025/day/6
3+
# 06/12/2025
4+
5+
# No blank line at end of file
6+
with open("input.txt") as file:
7+
inp = file.readlines()
8+
9+
nums = inp[:-1]
10+
big = max(nums, key=len)
11+
reals = []
12+
13+
# I needed to app something because
14+
# my algo needs to ops to calculate
15+
# the zone. I added something I could clean
16+
# easily
17+
ops = inp[-1].ljust(len(big), " ") + "\t"
18+
19+
# The zone is determined
20+
# by the operators
21+
22+
prev = 0
23+
for i in range(1, len(ops)):
24+
if ops[i] != ' ':
25+
real = []
26+
for row in nums:
27+
real.append(
28+
row[prev: i - 1] # Here
29+
)
30+
prev = i
31+
reals.append(real)
32+
33+
# We can clean ops now
34+
ops = ops.split()
35+
36+
from functools import reduce
37+
38+
res1, res2 = 0, 0
39+
default = {
40+
"+": 0,
41+
"*": 1
42+
}
43+
44+
for i in range(len(ops)):
45+
res1 += reduce(
46+
lambda a, b: eval(f"{a}{ops[i]}{b}"),
47+
reals[i],
48+
default[ops[i]]
49+
)
50+
51+
# reals is all centered already
52+
# They all have same length
53+
# in each row
54+
55+
final = ["" for _ in range(len(reals[i][0]))]
56+
for j in range(len(final)):
57+
for n in reals[i]:
58+
final[j] += n[j]
59+
# I strip for not to have a
60+
# space in the middle
61+
final[j] = final[j].strip()
62+
63+
64+
res2 += reduce(
65+
lambda a, b: eval(f"{a}{ops[i]}{b}"),
66+
final,
67+
default[ops[i]]
68+
)
69+
70+
print(res1, res2)

aoc/2025/06/animated/06_animated.vn.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

aoc/2025/06/normal/06_normal.vn.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)