Skip to content

Commit bf2def5

Browse files
committed
Completed day 25 of year 2024
1 parent 7bab3bd commit bf2def5

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

2024/25.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
split_data = '\n\n'
5+
completed = 1
6+
raw_data = None # Not To be touched
7+
8+
def part1(data):
9+
locks = []
10+
keys = []
11+
for schematic in data:
12+
schematic = schematic.split('\n')
13+
if schematic[0][0] == '.': # Key
14+
heights = [0, 0, 0, 0, 0]
15+
for col in range(5):
16+
for row in range(5):
17+
if schematic[5-row][col] == '#':
18+
heights[col] += 1
19+
else:
20+
break
21+
keys.append(heights)
22+
else: # Lock
23+
heights = [0, 0, 0, 0, 0]
24+
for col in range(5):
25+
for row in range(5):
26+
if schematic[1+row][col] == '#':
27+
heights[col] += 1
28+
else:
29+
break
30+
locks.append(heights)
31+
32+
fits = 0
33+
for lock in locks:
34+
for key in keys:
35+
for ch1, ch2 in zip(lock, key):
36+
if ch1 + ch2 > 5:
37+
break
38+
else:
39+
fits += 1
40+
41+
return fits
42+
43+
def part2(data):
44+
...

0 commit comments

Comments
 (0)