with open("input.txt") as f: pipes = f.read().splitlines() def part1(pipes): start = [ (i, j) for i, line in enumerate(pipes) for j, char in enumerate(line) if char == "S" ][0] distance = [([0] * len(pipes[0]))] * len(pipes) x, y = start d = 0