day8 part 2 work in progress, still not working
This commit is contained in:
@@ -39,8 +39,12 @@ class Node:
|
||||
|
||||
def is_A_node(self):
|
||||
return self.value[2] == 'A'
|
||||
|
||||
def is_Z_node(self):
|
||||
return self.value[2] == 'Z'
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.value} = ({self.left}, {self.right})"
|
||||
|
||||
|
||||
def parse(input_file:str) -> Tuple[str, List[Node]]:
|
||||
@@ -48,7 +52,7 @@ def parse(input_file:str) -> Tuple[str, List[Node]]:
|
||||
with open(input_file) as input:
|
||||
directions = input.readline().replace("\n","")
|
||||
_ = input.readline()
|
||||
while match:= re.match("([A-Z]+) = \(([A-Z]+), ([A-Z]+)\)",input.readline()):
|
||||
while match:= re.match("([A-Z]+) = \(([A-Z]+), ([A-Z]+)\)", input.readline()):
|
||||
node = Node(value=match.group(1), left=match.group(2), right=match.group(3))
|
||||
the_list.append(node)
|
||||
return directions, the_list
|
||||
Reference in New Issue
Block a user