field and has to reach the bottom-right corner. A cell holding 1 is a hazard: every time the robot steps onto it, the robot loses 1 health point. Cells holding 0 are safe. The starting cell counts too: if it is a hazard, a point is lost right away.
In one step the robot moves to the neighbouring cell up, down, left or right. It starts with hp health points and is out as soon as its health reaches 0.
Return True if the robot can reach the bottom-right corner with at least 1 health point left, and False otherwise.field=[[0, 1, 1], [0, 0, 1], [1, 0, 0]], hp=1 → True
Going down, right, down, right touches only safe cells, so the single health point survives to the end.
field=[[0, 1], [1, 0]], hp=1 → False
Every route steps on one hazard cell, and health drops to 0.
field=[[1, 1, 0], [0, 1, 1]], hp=4 → True
The starting cell itself is a hazard. For example, the route right, right, down hits one more at the end: 3 in total, leaving 1 point.
len(field), len(field[0]) ≤ 50hp ≤ len(field) + len(field[0])field=[[0, 1, 1], [0, 0, 1], [1, 0, 0]], hp=1
True
Run checks the first 3 tests in your browser. Submit checks all 78 tests on the server, hidden ones included.