diff --git a/day15.py b/day15.py new file mode 100644 index 0000000..e0ef3e3 --- /dev/null +++ b/day15.py @@ -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) diff --git a/inputs/input15_test1 b/inputs/input15_test1 new file mode 100644 index 0000000..63d31fe --- /dev/null +++ b/inputs/input15_test1 @@ -0,0 +1,7 @@ +####### +#.G...# +#...EG# +#.#.#G# +#..G#E# +#.....# +####### \ No newline at end of file diff --git a/inputs/input15_test2 b/inputs/input15_test2 new file mode 100644 index 0000000..d1ea04d --- /dev/null +++ b/inputs/input15_test2 @@ -0,0 +1,7 @@ +####### +#G..#E# +#E#E.E# +#G.##.# +#...#E# +#...E.# +####### \ No newline at end of file diff --git a/inputs/input15_test3 b/inputs/input15_test3 new file mode 100644 index 0000000..ec665ae --- /dev/null +++ b/inputs/input15_test3 @@ -0,0 +1,7 @@ +####### +#E..EG# +#.#G.E# +#E.##E# +#G..#.# +#..E#.# +####### \ No newline at end of file diff --git a/inputs/input15_test4 b/inputs/input15_test4 new file mode 100644 index 0000000..9929491 --- /dev/null +++ b/inputs/input15_test4 @@ -0,0 +1,7 @@ +####### +#E.G#.# +#.#G..# +#G.#.G# +#G..#.# +#...E.# +####### \ No newline at end of file diff --git a/inputs/input15_test5 b/inputs/input15_test5 new file mode 100644 index 0000000..5541989 --- /dev/null +++ b/inputs/input15_test5 @@ -0,0 +1,7 @@ +####### +#.E...# +#.#..G# +#.###.# +#E#G#G# +#...#G# +####### \ No newline at end of file diff --git a/inputs/input15_test6 b/inputs/input15_test6 new file mode 100644 index 0000000..dca8b76 --- /dev/null +++ b/inputs/input15_test6 @@ -0,0 +1,9 @@ +######### +#G......# +#.E.#...# +#..##..G# +#...##..# +#...#...# +#.G...G.# +#.....G.# +######### \ No newline at end of file