Water spread simulation
A plant nursery waters its growing beds from a single valve. The bench layout arrives as a rectangular grid of one character plots: '.' is a level plot that water runs across, '#' is a raised ridge that water cannot get over, and 'D' is a soak away pit that takes water in but never passes any on. Water enters the plot at valve_row and valve_col, then reaches any plot that shares an edge with a plot already wet. Diagonals do not count, since the ridges run corner to corner. Return how many plots end up wet, including the plot the valve sits on. Return 0 when the valve sits outside the layout or on a ridge, because then nothing is watered. A layout with no rows returns 0. Every row has the same width.
wet_plot_count(layout: list[list[str]], valve_row: int, valve_col: int) → int[[[".",".",".","."],[".","#","#","."],[".",".",".","."]],0,0]out10[[[".","D","."]],0,0]out2[[[".","#","."],["#","#","#"],[".",".","."]],0,0]out1State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[[".",".",".","."],[".","#","#","."],[".",".",".","."]],0,0]10not run yetsample[[[".","D","."]],0,0]2not run yetsample[[[".","#","."],["#","#","#"],[".",".","."]],0,0]1not run yetsample