-
Notifications
You must be signed in to change notification settings - Fork 0
/
part_b.py
executable file
·59 lines (53 loc) · 1.7 KB
/
part_b.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import utils
from year_2018.day_17 import part_a
class Challenge(utils.BaseChallenge):
def solve(self, _input, debug=False):
"""
>>> Challenge().default_solve()
22182
"""
ground = GroundExtended.from_ground_text(_input)
ground.step_many()
return ground.get_settled_water_reach()
class GroundExtended(part_a.Ground):
def get_settled_water_reach(self):
"""
>>> GroundExtended.from_visual(
... ".....+......\\n"
... ".....|.....#\\n"
... "#..#||||...#\\n"
... "#..#~~#|....\\n"
... "#..#~~#|....\\n"
... "#~~~~~#|....\\n"
... "#~~~~~#|....\\n"
... "#######|....\\n"
... ".......|....\\n"
... "..|||||||||.\\n"
... "..|#~~~~~#|.\\n"
... "..|#~~~~~#|.\\n"
... "..|#~~~~~#|.\\n"
... "..|#######|.\\n"
... , spring_water_points=False).get_settled_water_reach()
29
>>> GroundExtended.from_visual(
... ".....+......\\n"
... ".....|......\\n"
... "#..#||||...#\\n"
... "#..#~~#|....\\n"
... "#..#~~#|....\\n"
... "#~~~~~#|....\\n"
... "#~~~~~#|....\\n"
... "#######|....\\n"
... ".......|....\\n"
... "..|||||||||.\\n"
... "..|#~~~~~#|.\\n"
... "..|#~~~~~#|.\\n"
... "..|#~~~~~#|.\\n"
... "..|#######|.\\n"
... , spring_water_points=False).get_settled_water_reach()
29
"""
return len(self.settled_water)
Challenge.main()
challenge = Challenge()