A Python program operates on a 3x3 automated warehouse storage grid containing cargo containers numbered from 1 to 8, with one empty bay represented by 0.
The subroutines available for controlling the automated system are described in the table below:
| Subroutine | Purpose |
|---|---|
inspectBay(row, column) | Returns the ID of the cargo container in the storage grid in position (row, column). The value 0 represents an empty bay. |
shiftItem(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 | 7 | 2 |
| Row 1 | 1 | 0 | 5 |
| Row 2 | 8 | 3 | 6 |
if inspectBay(1, 1) == 0:
shiftItem(2, 1)
if inspectBay(2, 1) == 0:
shiftItem(2, 2)
Complete the table below to show the final state of the storage grid after the program has run.
| Column 0 | Column 1 | Column 2 | |
|---|---|---|---|
| Row 0 | |||
| Row 1 | |||
| Row 2 |