aboutsummaryrefslogtreecommitdiff
path: root/2025/12/a-if-it-was-serious.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--2025/12/a-if-it-was-serious.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/2025/12/a-if-it-was-serious.py b/2025/12/a-if-it-was-serious.py
new file mode 100644
index 0000000..59ffd72
--- /dev/null
+++ b/2025/12/a-if-it-was-serious.py
@@ -0,0 +1,45 @@
1import fileinput
2
3class Present:
4 def __init__(self, lines5):
5 self.baseshape = [line[:-1] for line in lines5[1:4]]
6 self.area = sum(l.count('#') for l in self.baseshape)
7
8 @staticmethod
9 def pretty(s):
10 return '\n'.join(s)
11
12 def __str__(self):
13 return Present.pretty(self.baseshape)
14
15 @staticmethod
16 def singlerot(s):
17 return [''.join(s[j][2-i] for j in range(3)) for i in range(3)]
18
19 @staticmethod
20 def singleflip(s):
21 return [''.join(s[i][2-j] for j in range(3)) for i in range(3)]
22
23 def shape(self, rot, flip):
24 s = list(self.baseshape)
25 for _ in range(rot):
26 s = Present.singlerot(s)
27 if flip:
28 s = Present.singleflip(s)
29 return s
30
31class Region:
32 def __init__(self, line):
33 wh, n = line[:-1].split(': ')
34 self.w, self.h = tuple(int(i) for i in wh.split('x'))
35 self.p = [int(i) for i in n.split(' ')]
36
37 def __str__(self):
38 return f"({self.w}x{self.h}) {self.p}"
39
40with fileinput.input() as lines:
41 lines = list(lines)
42 presents = [Present(lines[5*i:5*(i+1)]) for i in range(6)]
43 regions = [Region(line) for line in lines[30:]]
44
45# Then you'd have to find some algorithm to solve this, but it is crazy hard

Generated with cgit - Back to sebastiano.tronto.net