File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/adventofcode/year_2015 Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1- from typing import List , Dict
1+ from typing import List , Dict , Optional
22
33from adventofcode .util .exceptions import SolutionNotFoundException
44from adventofcode .util .helpers import solution_timer
@@ -44,11 +44,13 @@ def parse_lines(input_data: List[str]) -> List[Aunt]:
4444 return aunts
4545
4646
47- def find_aunt_sue (aunts : List [Aunt ]) -> Aunt :
47+ def find_aunt_sue (aunts : List [Aunt ]) -> Optional [ Aunt ] :
4848 for aunt in aunts :
4949 if all_properties_match (aunt ):
5050 return aunt
5151
52+ return None
53+
5254
5355def find_aunt_sue_part_two (aunts : List [Aunt ]) -> Aunt :
5456 aunts = [aunt for aunt in aunts if matches_part_two (aunt )]
@@ -84,7 +86,12 @@ def matches_part_two(aunt: Aunt) -> bool:
8486@solution_timer (2015 , 16 , 1 )
8587def part_one (input_data : List [str ]):
8688 aunts = parse_lines (input_data )
87- answer = find_aunt_sue (aunts ).number
89+ aunt = find_aunt_sue (aunts )
90+
91+ if not aunt :
92+ raise SolutionNotFoundException (2015 , 16 , 1 )
93+
94+ answer = aunt .number
8895
8996 if not answer :
9097 raise SolutionNotFoundException (2015 , 16 , 1 )
You can’t perform that action at this time.
0 commit comments