day15 start
This commit is contained in:
parent
b8c11565c7
commit
f907be2b20
58
day15.py
Normal file
58
day15.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
from enum import Enum
|
||||||
|
from tools.aoc import AOCDay
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from tools.grid import Grid
|
||||||
|
|
||||||
|
|
||||||
|
class UnitType(int, Enum):
|
||||||
|
GOBLIN = 1
|
||||||
|
ELF = 2
|
||||||
|
|
||||||
|
|
||||||
|
class Unit:
|
||||||
|
def __init__(self, unit_type: UnitType):
|
||||||
|
self.unit_type = unit_type
|
||||||
|
self.hit_points = 300
|
||||||
|
self.attack_power = 3
|
||||||
|
|
||||||
|
|
||||||
|
class Day(AOCDay):
|
||||||
|
inputs = [
|
||||||
|
[
|
||||||
|
(27730, "input15_test1"),
|
||||||
|
(36334, "input15_test2"),
|
||||||
|
(39514, "input15_test3"),
|
||||||
|
(27755, "input15_test4"),
|
||||||
|
(28944, "input15_test5"),
|
||||||
|
(18740, "input15_test6"),
|
||||||
|
(None, "input15"),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
(None, "input15"),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
|
||||||
|
def parse_input(self) -> Grid:
|
||||||
|
grid = Grid.from_data(self.getInput())
|
||||||
|
for c in grid.getActiveCells():
|
||||||
|
if grid.get(c) not in "EG":
|
||||||
|
continue
|
||||||
|
|
||||||
|
if grid.get(c) == "E":
|
||||||
|
grid.set(c, Unit(UnitType.ELF))
|
||||||
|
else:
|
||||||
|
grid.set(c, Unit(UnitType.GOBLIN))
|
||||||
|
|
||||||
|
return grid
|
||||||
|
|
||||||
|
def part1(self) -> Any:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def part2(self) -> Any:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
day = Day(2018, 15)
|
||||||
|
day.run(verbose=True)
|
||||||
7
inputs/input15_test1
Normal file
7
inputs/input15_test1
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#######
|
||||||
|
#.G...#
|
||||||
|
#...EG#
|
||||||
|
#.#.#G#
|
||||||
|
#..G#E#
|
||||||
|
#.....#
|
||||||
|
#######
|
||||||
7
inputs/input15_test2
Normal file
7
inputs/input15_test2
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#######
|
||||||
|
#G..#E#
|
||||||
|
#E#E.E#
|
||||||
|
#G.##.#
|
||||||
|
#...#E#
|
||||||
|
#...E.#
|
||||||
|
#######
|
||||||
7
inputs/input15_test3
Normal file
7
inputs/input15_test3
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#######
|
||||||
|
#E..EG#
|
||||||
|
#.#G.E#
|
||||||
|
#E.##E#
|
||||||
|
#G..#.#
|
||||||
|
#..E#.#
|
||||||
|
#######
|
||||||
7
inputs/input15_test4
Normal file
7
inputs/input15_test4
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#######
|
||||||
|
#E.G#.#
|
||||||
|
#.#G..#
|
||||||
|
#G.#.G#
|
||||||
|
#G..#.#
|
||||||
|
#...E.#
|
||||||
|
#######
|
||||||
7
inputs/input15_test5
Normal file
7
inputs/input15_test5
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#######
|
||||||
|
#.E...#
|
||||||
|
#.#..G#
|
||||||
|
#.###.#
|
||||||
|
#E#G#G#
|
||||||
|
#...#G#
|
||||||
|
#######
|
||||||
9
inputs/input15_test6
Normal file
9
inputs/input15_test6
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#########
|
||||||
|
#G......#
|
||||||
|
#.E.#...#
|
||||||
|
#..##..G#
|
||||||
|
#...##..#
|
||||||
|
#...#...#
|
||||||
|
#.G...G.#
|
||||||
|
#.....G.#
|
||||||
|
#########
|
||||||
Loading…
Reference in New Issue
Block a user