Sensor firmware propagation
Your task
A factory covers its floor with a mesh of sensor nodes laid out on a rectangular grid, one cell per position. A cell holds '.' for a node and '#' for a steel press, which blocks radio outright. A firmware update starts at the gateway node at gateway_row and gateway_col and travels in hops: on each hop every node that already holds the update passes it to the nodes sharing an edge, never diagonally and never through a press. A node takes the update on the earliest hop that reaches it and never again. Return a list of length hops plus 1 where the entry at index d is how many nodes first receive the update on hop d, so index 0 counts the gateway itself. Return that list filled with zeros when the grid has no cells, when the gateway sits outside it, or when the gateway sits on a press. hops is never negative, and every row has the same width.
Examples
mesh_hop_counts(layout: list[list[str]], gateway_row: int, gateway_col: int, hops: int) -> list[int]mesh_hop_counts([[".", ".", "."], [".", "#", "."], [".", ".", "."]], 0, 0, 2)[1, 2, 2]mesh_hop_counts([[".", "#"], ["#", "."]], 0, 0, 3)[1, 0, 0, 0]mesh_hop_counts([[".", ".", ".", ".", "."]], 0, 2, 3)[1, 2, 2, 0]