aboutsummaryrefslogtreecommitdiff
path: root/2025/12/a-if-it-was-serious.py
blob: 59ffd72c04271ddb8341273f64a95f4820120412 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import fileinput

class Present:
	def __init__(self, lines5):
		self.baseshape = [line[:-1] for line in lines5[1:4]]
		self.area = sum(l.count('#') for l in self.baseshape)

	@staticmethod
	def pretty(s):
		return '\n'.join(s)

	def __str__(self):
		return Present.pretty(self.baseshape)

	@staticmethod
	def singlerot(s):
		return [''.join(s[j][2-i] for j in range(3)) for i in range(3)]

	@staticmethod
	def singleflip(s):
		return [''.join(s[i][2-j] for j in range(3)) for i in range(3)]

	def shape(self, rot, flip):
		s = list(self.baseshape)
		for _ in range(rot):
			s = Present.singlerot(s)
		if flip:
			s = Present.singleflip(s)
		return s

class Region:
	def __init__(self, line):
		wh, n = line[:-1].split(': ')
		self.w, self.h = tuple(int(i) for i in wh.split('x'))
		self.p = [int(i) for i in n.split(' ')]

	def __str__(self):
		return f"({self.w}x{self.h}) {self.p}"

with fileinput.input() as lines:
	lines = list(lines)
	presents = [Present(lines[5*i:5*(i+1)]) for i in range(6)]
	regions = [Region(line) for line in lines[30:]]

# Then you'd have to find some algorithm to solve this, but it is crazy hard

Generated with cgit - Back to sebastiano.tronto.net