Skip to content

Commit

Permalink
AoC 2023 Day 16 Part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pareronia committed Dec 16, 2023
1 parent bea2a52 commit 91f6052
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- @BEGIN:ImplementationsTable:2023@ -->
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| ---| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| python3 | [](src/main/python/AoC2023_01.py) | [](src/main/python/AoC2023_02.py) | [](src/main/python/AoC2023_03.py) | [](src/main/python/AoC2023_04.py) | [](src/main/python/AoC2023_05.py) | [](src/main/python/AoC2023_06.py) | [](src/main/python/AoC2023_07.py) | [](src/main/python/AoC2023_08.py) | [](src/main/python/AoC2023_09.py) | [](src/main/python/AoC2023_10.py) | [](src/main/python/AoC2023_11.py) | [](src/main/python/AoC2023_12.py) | [](src/main/python/AoC2023_13.py) | [](src/main/python/AoC2023_14.py) | [](src/main/python/AoC2023_15.py) | | | | | | | | | | |
| python3 | [](src/main/python/AoC2023_01.py) | [](src/main/python/AoC2023_02.py) | [](src/main/python/AoC2023_03.py) | [](src/main/python/AoC2023_04.py) | [](src/main/python/AoC2023_05.py) | [](src/main/python/AoC2023_06.py) | [](src/main/python/AoC2023_07.py) | [](src/main/python/AoC2023_08.py) | [](src/main/python/AoC2023_09.py) | [](src/main/python/AoC2023_10.py) | [](src/main/python/AoC2023_11.py) | [](src/main/python/AoC2023_12.py) | [](src/main/python/AoC2023_13.py) | [](src/main/python/AoC2023_14.py) | [](src/main/python/AoC2023_15.py) | [](src/main/python/AoC2023_16.py) | | | | | | | | | |
| java | [](src/main/java/AoC2023_01.java) | [](src/main/java/AoC2023_02.java) | [](src/main/java/AoC2023_03.java) | [](src/main/java/AoC2023_04.java) | [](src/main/java/AoC2023_05.java) | [](src/main/java/AoC2023_06.java) | [](src/main/java/AoC2023_07.java) | [](src/main/java/AoC2023_08.java) | [](src/main/java/AoC2023_09.java) | [](src/main/java/AoC2023_10.java) | [](src/main/java/AoC2023_11.java) | [](src/main/java/AoC2023_12.java) | [](src/main/java/AoC2023_13.java) | [](src/main/java/AoC2023_14.java) | [](src/main/java/AoC2023_15.java) | | | | | | | | | | |
| rust | [](src/main/rust/AoC2023_01/src/main.rs) | [](src/main/rust/AoC2023_02/src/main.rs) | [](src/main/rust/AoC2023_03/src/main.rs) | [](src/main/rust/AoC2023_04/src/main.rs) | | [](src/main/rust/AoC2023_06/src/main.rs) | [](src/main/rust/AoC2023_07/src/main.rs) | [](src/main/rust/AoC2023_08/src/main.rs) | [](src/main/rust/AoC2023_09/src/main.rs) | | | | | | [](src/main/rust/AoC2023_15/src/main.rs) | | | | | | | | | | |
<!-- @END:ImplementationsTable:2023@ -->
Expand Down
50 changes: 46 additions & 4 deletions src/main/python/AoC2023_16.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,63 @@ def get_energised(
return ans

def part_1(self, grid: Input) -> Output1:
sys.setrecursionlimit(10_000)
log_grid(grid)
energised = self.get_energised(
grid, Cell(0, 0), Direction.RIGHT, set()
)
log(draw(energised, "#", "."))
return len(energised)

def part_2(self, input: Input) -> Output2:
return 0
def part_2(self, grid: Input) -> Output2:
sys.setrecursionlimit(10_000)
ans = 0
for row in range(grid.get_height()):
ans = max(
ans,
len(
self.get_energised(
grid, Cell(row, 0), Direction.RIGHT, set()
)
),
)
ans = max(
ans,
len(
self.get_energised(
grid,
Cell(row, grid.get_width() - 1),
Direction.LEFT,
set(),
)
),
)
for col in range(grid.get_width()):
ans = max(
ans,
len(
self.get_energised(
grid, Cell(0, col), Direction.DOWN, set()
)
),
)
ans = max(
ans,
len(
self.get_energised(
grid,
Cell(grid.get_height() - 1, col),
Direction.UP,
set(),
)
),
)
return ans

@aoc_samples(
(
("part_1", TEST, 46),
# ("part_2", TEST, "TODO"),
("part_2", TEST, 51),
)
)
def samples(self) -> None:
Expand All @@ -153,7 +196,6 @@ def samples(self) -> None:


def main() -> None:
sys.setrecursionlimit(10_000)
solution.run(sys.argv)


Expand Down

0 comments on commit 91f6052

Please sign in to comment.