door = [x, y]. There are guards on the grid: guards[i] = [xi, yi] is where the i-th guard starts. Several guards may share a cell.
Each turn takes one unit of time. During a turn, you and every guard simultaneously and independently either move one cell up, down, left or right, or stay put.
You escape if you reach the exit before any guard ends up in the same cell as you. If you and a guard arrive at the same cell at the same moment (the exit included), you are caught.
Return True if you can escape for sure no matter how the guards move, and False otherwise.guards=[[3, 3], [-2, 0]], door=[0, 2] → True
We are 2 steps from the door. The guard at (3, 3) is 4 steps away from it, and so is the one at (-2, 0). We make it.
guards=[[1, 3]], door=[2, 2] → False
Both we and the guard are 4 steps from the door: the guard can just stand at the door and wait, so there is no escape.
guards=[[5, -5]], door=[0, 0] → True
We already stand on the door, and the guard is far away.
guards=[[3, 3], [-2, 0]], door=[0, 2]
True
Run checks the first 3 tests in your browser. Submit checks all 141 tests on the server, hidden ones included.