Start day 22.
This commit is contained in:
parent
ed7149e5f4
commit
6ade69ac35
@ -1,5 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
|
@ -1,3 +1,38 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
|
||||
EMPTY = 0
|
||||
VOID = 1
|
||||
WALL = 2
|
||||
TILE_FROM_CHAR = {" ": VOID, ".": EMPTY, "#": WALL}
|
||||
|
||||
|
||||
board_map_s, direction_s = sys.stdin.read().split("\n\n")
|
||||
|
||||
# board
|
||||
board_lines = board_map_s.splitlines()
|
||||
max_line = max(len(line) for line in board_lines)
|
||||
board_map = np.array(
|
||||
[
|
||||
[TILE_FROM_CHAR[c] for c in row] + [VOID] * (max_line - len(row))
|
||||
for row in board_map_s.splitlines()
|
||||
]
|
||||
)
|
||||
|
||||
directions = [
|
||||
int(p1) if p2 else p1 for p1, p2 in re.findall(R"(([0-9])+|L|R)", direction_s)
|
||||
]
|
||||
|
||||
y0 = 0
|
||||
x0 = np.where(board_map[0] == EMPTY)[0][0]
|
||||
r0 = "R"
|
||||
print(y0, x0)
|
||||
|
||||
for direction in directions:
|
||||
if isinstance(direction, int):
|
||||
if r0 == "R":
|
||||
x0 = np.argmax(board_map[y0, x0 + 1 :])
|
||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,14 @@
|
||||
...#
|
||||
.#..
|
||||
#...
|
||||
....
|
||||
...#.......#
|
||||
........#...
|
||||
..#....#....
|
||||
..........#.
|
||||
...#....
|
||||
.....#..
|
||||
.#......
|
||||
......#.
|
||||
|
||||
10R5L5R10L4R5L5
|
Loading…
Reference in New Issue
Block a user