File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change 1+ import numpy
2+
3+ from . import CombinedRunner
4+
5+
6+ class DayRunner (CombinedRunner ):
7+ @classmethod
8+ def run_both (cls , input : str ) -> tuple [int , None ]:
9+ blocks = input .strip ().split ("\n \n " )
10+
11+ keys = []
12+ locks = []
13+
14+ for block in blocks :
15+ grid = numpy .array (list (map (list , block .splitlines ())))
16+ heights = numpy .count_nonzero (grid == "#" , axis = 0 )
17+
18+ if block .startswith ("#####" ):
19+ locks .append (heights )
20+ else :
21+ keys .append (heights )
22+
23+ fitting = 0
24+
25+ for key in keys :
26+ for lock in locks :
27+ if numpy .all ((key + lock ) <= 7 ):
28+ fitting += 1
29+
30+ return fitting , None
Original file line number Diff line number Diff line change 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+ #####
Original file line number Diff line number Diff line change 1+ from aoc .days .day25 import DayRunner
2+
3+ from . import get_data
4+
5+
6+ def test_sample_part1 () -> None :
7+ assert DayRunner .part1 (get_data (25 )) == 3
You can’t perform that action at this time.
0 commit comments