from lib import get_data, str_to_ints, Grid2D, add2 from collections import defaultdict from d9 import Amp DIRS = [ (-1, 0), (0, 1), (1, 0), (0, -1), ] DIRCHAR = list("^>v<") def find_path(g): (pos,) = g.find("^>