Episode 22
The Missing Tile
When there's a piece missing, Robot demonstrates how to count through the rows to get the correct pocket.


















Episode transcript
A tile has gone missing
Robot has a loose tile in his hand. There is a strip below with 12 pockets.
Diagram values: 3 rows × 4 columns
Duck: But how do you get 3 rows of square tiles in this case that has only one long strip of pockets?
Duck points at top-left cell. Both row and col are 0.
Diagram values: Rows: 0, 1, 2; Columns: 0, 1, 2, 3
Robot: Start counting from 0 (row and column).
Duck draws the first 4 squares (left to right) from 0 to 3.
Diagram values: Row 0: 0, 1, 2, 3; Row 1: 4, 5, 6, 7
Duck: The whole row is written out first.
There's one golden square which is the spot where you put the loose piece. That's the 2nd column from left on the bottom row.
Diagram values: Target: row 2, column 1
Robot: Where is my row 2, column 1 pocket?
Count full rows first
The first two full rows equal 8 cells.
Diagram values: 2 × 4 = 8
Robot: There are 2 whole rows preceding row 2.
The bottom row starts at pocket 8. 1 cell to the right of that is pocket 9.
Diagram values: 8 + 1 = 9
Duck: The bottom row starts at pocket 8. 1 cell to the right of that is pocket 9.
Then the robot draws a line between that mosaic cell and the pocket nine.
Diagram values: Cell (2, 1) ↔ Pocket 9
Robot: The strip index becomes nine.
Duck peels a sticky note open. First row is zero.
Diagram values: First row: 0
Duck: I almost said first row would be row 1.
Robot points at grid and equation. Two full rows of 4 and one extra space make pocket 9.
Diagram values: Index = row × 4 + column; 2 × 4 + 1 = 9
Robot: Our rule is (row)x(width) + column.
Follow the strip backwards
Duck has the 6-tile.
Diagram values: Index 6; Width 4
Duck: Where does it fit in the mosaic?
Robot points at four marbles + the mosaic. One row is filled with four cells.
Diagram values: 6 = 1 × 4 + 2
Robot: That's one full row. So we have two more slots.
Duck is holding the turquoise one up to the board. The square that's highlighted is pocket 6.
Diagram values: Pocket 6 ↔ Cell (1, 2)
Duck: Row one column two.
Robot is in front of 2 clipboards.
Diagram values: Width 4; Counting starts at 0
Robot: Same width.
The last pocket
Duck shows another tile. Number 11 on it. Robot covers answer.
Diagram values: Index 11
Duck: Last challenge. What's row and column for pocket eleven?
Robot puts two complete sets of 4 pieces together and has 3 pieces in a bowl.
Diagram values: 11 = 2 × 4 + 3
Robot: 11 = two groups of four plus three.
Duck puts the gold tile down at the bottom right of the mosaic. The tile is labeled 11.
Diagram values: Pocket 11 ↔ Cell (2, 3)
Duck: Row 2. Column 3. The last cell!
There are 12 cells in total. Last cell is marked with number 11.
Diagram values: Cell count: 12; Last index: 11
Robot: There are twelve cells. We will index them from zero to eleven.
The completed glass mosaic glows against the backdrop of a drawer full of random boots. Duck looks into the drawer. Robot smiles.
Duck: All tiles have pockets. Ugh, my boots are still in the wrong drawer.
The lesson
There are 3 rows in this mosaic. Each row has 4 cells. Rows and columns are numbered from 0. This is a row major ordering. That is, each row takes up 4 pockets in a row before starting the next. Row 2, column 1 is after 2 whole rows + 1 tile. For each whole row, there are 4 pockets. The number of the pocket is 2 * 4 + 1 = 9. To find the mapping in reverse, take the index / 4. The integer portion gives the row, the remainder the column. So index 6 is row 1 column 2.
Try it
Diagram values: 3 rows × 4 columns, numbered from 0; Cell (1, 3); Pocket 8
What index is row one column three? What row and column are index eight?
Answer
Diagram values: 1 × 4 + 3 = 7; 8 = 2 × 4 + 0; Pocket 8 ↔ Cell (2, 0)
Row 1 column 3 has index 1*4+3 = 7. Eight divided by four gives quotient 2 and remainder 0. Therefore index 8 is in row 2 column 0.