An automated cargo system operates on a 3x3 distribution grid of shipping containers. Each cell contains a container of a specific weight (in tons) from 1 to 9, with one empty bay represented by 0.
The subroutines available for managing the grid are described in the table below:
| Subroutine | Purpose |
|---|---|
getWeight(row, column) | Returns the weight of the container on the grid at position (row, column). The value 0 represents the empty bay. |
shift(row, column) | Shifts the container at (row, column) into the adjacent empty bay, if the empty bay is directly next to it (horizontally or vertically). |
| Column 0 | Column 1 | Column 2 | |
|---|---|---|---|
| Row 0 | 4 | 9 | 1 |
| Row 1 | 0 | 5 | 7 |
| Row 2 | 3 | 2 | 8 |
if getWeight(1, 0) == 0:
shift(0, 0)
if getWeight(0, 0) == 0:
shift(0, 1)
Complete the table below to show the final state of the grid after the program has run.
| Column 0 | Column 1 | Column 2 | |
|---|---|---|---|
| Row 0 | |||
| Row 1 | |||
| Row 2 |