向矩陣中的四個方向移動

row = 0
col = 0
directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
for drow, dcol in directions:
    if 0 <= row + drow < rows and 0 <= col + dcol < cols:
        # Do Something
Robot Bounded In Circle 掃地機器人

Last updated