|
@ -29,8 +29,10 @@ class VolcanicVent: |
|
|
end: Location |
|
|
end: Location |
|
|
|
|
|
|
|
|
def __post_init__(self): |
|
|
def __post_init__(self): |
|
|
if self.start.x == self.end.x or self.start.y == self.end.y: |
|
|
|
|
|
self.direction = "vertical" if self.start.x == self.end.x else "horizontal" |
|
|
|
|
|
|
|
|
if self.start.x == self.end.x: |
|
|
|
|
|
self.direction = "vertical" |
|
|
|
|
|
elif self.start.y == self.end.y: |
|
|
|
|
|
self.direction = "horizontal" |
|
|
else: |
|
|
else: |
|
|
self.direction = "diagnal" |
|
|
self.direction = "diagnal" |
|
|
|
|
|
|
|
@ -90,12 +92,10 @@ def parse(inputs: str) -> List[int]: |
|
|
results = [] |
|
|
results = [] |
|
|
for line in inputs.split("\n"): |
|
|
for line in inputs.split("\n"): |
|
|
start_end = line.split(" -> ") |
|
|
start_end = line.split(" -> ") |
|
|
start_split = start_end[0].split(",") |
|
|
|
|
|
end_split = start_end[1].split(",") |
|
|
|
|
|
results.append( |
|
|
results.append( |
|
|
VolcanicVent( |
|
|
VolcanicVent( |
|
|
start=Location(x=start_split[0], y=start_split[1]), |
|
|
|
|
|
end=Location(x=end_split[0], y=end_split[1]), |
|
|
|
|
|
|
|
|
start=Location(*start_end[0].split(",")), |
|
|
|
|
|
end=Location(*start_end[1].split(",")), |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return results |
|
|
return results |
|
|