Roof cell shading
Your task
A solar contractor models late afternoon shading on a flat roof. The roof arrives as a rectangular grid of cells, and heights[r][c] holds the height in centimetres of whatever stands on that cell, with 0 for bare deck and no negative values. The sun sits low on one side, so light crosses the roof in straight lines from the side named by light_from: 'W' runs it left to right along each row, 'E' right to left along each row, 'N' top to bottom down each column, and 'S' bottom to top up each column. A cell is shaded when some cell the light already passed on that same line stands strictly taller than it. Equal height clears. Return every shaded cell as a [row, column] pair, sorted by row and then by column. Every row has the same width.
Examples
shaded_panel_cells(heights: list[list[int]], light_from: str) -> list[list[int]]Example 1
Input
shaded_panel_cells([[3, 1, 2], [1, 4, 4]], "W")Output
[[0, 1], [0, 2]]Example 2
Input
shaded_panel_cells([[3, 1, 2], [1, 4, 4]], "E")Output
[[0, 1], [1, 0]]Example 3
Input
shaded_panel_cells([[2, 2], [1, 3]], "N")Output
[[1, 0]]