day11
This commit is contained in:
parent
dfb8e09ec9
commit
92d839a4e8
36
day11.py
Normal file
36
day11.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
from tools.aoc import AOCDay
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from tools.coordinate import HexCoordinateF, DistanceAlgorithm
|
||||||
|
|
||||||
|
|
||||||
|
class Day(AOCDay):
|
||||||
|
inputs = [
|
||||||
|
[
|
||||||
|
(796, "input11")
|
||||||
|
],
|
||||||
|
[
|
||||||
|
(1585, "input11")
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
def part1(self) -> Any:
|
||||||
|
start = HexCoordinateF(0, 0, 0)
|
||||||
|
for x in self.getInputAsArraySplit(','):
|
||||||
|
start += HexCoordinateF.neighbour_vectors[x]
|
||||||
|
return start.getDistanceTo(HexCoordinateF(0, 0, 0), DistanceAlgorithm.MANHATTAN)
|
||||||
|
|
||||||
|
def part2(self) -> Any:
|
||||||
|
init = HexCoordinateF(0, 0, 0)
|
||||||
|
start = HexCoordinateF(0, 0, 0)
|
||||||
|
max_dist = 0
|
||||||
|
for x in self.getInputAsArraySplit(','):
|
||||||
|
start += HexCoordinateF.neighbour_vectors[x]
|
||||||
|
max_dist = max(max_dist, start.getDistanceTo(init, DistanceAlgorithm.MANHATTAN))
|
||||||
|
|
||||||
|
return max_dist
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
day = Day(2017, 11)
|
||||||
|
day.run(verbose=True)
|
||||||
1
inputs/input11
Normal file
1
inputs/input11
Normal file
File diff suppressed because one or more lines are too long
0
start_day.py
Normal file → Executable file
0
start_day.py
Normal file → Executable file
Loading…
Reference in New Issue
Block a user