## Question 1 Given these values as input, which matrix represents the state of the matrix on day 4? **Note:** In the options, $1$ represents water. $rows = 3$ $cols = 3$ $water\_cells = [~[3, 2], ~[1, 3], ~[2, 2], ~[3, 1], ~[1, 1], ~[1, 2], ~[2, 3], ~[3, 3], ~[2, 1]]~$ ### Options 1. | 0 | 0 | 0 | - | 0 | 0 | 0 | - | 0 | 0 | 0 | - Incorrect None of the cells have been flooded. ---------------------------- 2. | 1 | 0 | 1 | - | 0 | 1 | 0 | - | 1 | 1 | 0 | - Incorrect Only four cells may be flooded by day 4. ---------------------------- 3. | 0 | 0 | 1 | - | 0 | 1 | 0 | - | 1 | 1 | 0 | - Correct * On day 1, as per the `water_cells` array, the cell in the $3^{rd}$ row and the $2^{nd}$ column, [3, 2], will get flooded. * On day 2, the cell in the $1^{st}$ row and the $3^{rd}$ column, [1, 3], will get flooded. * On day 3, the cell in the $2^{nd}$ row and the $2^{nd}$ column, [2, 2], will get flooded. * On day 4, the cell in the $3^{rd}$ row and the $1^{st}$ column, [3, 1], will get flooded. ---------------------------- 4. | 1 | 1 | 0 | - | 0 | 1 | 0 | - | 0 | 0 | 1 | - Incorrect The $1^{st}$ row is the top row, not the bottom row. ---------------------------- --------------------------------------------- ## Question 2 Given these values as input, which row will be the first to be completely flooded? $rows = 4$ $cols = 3$ $water\_cells = [~[2, 3], ~[1, 1], ~[2, 1], ~[4, 3], ~[3, 3], ~[4, 1], ~[4, 2], ~[1, 3], ~[3, 2], ~[1, 2], ~[2, 2], ~[3, 1]~]$ ### Options 1. 1 Incorrect ---------------------------- 2. 2 Incorrect ---------------------------- 3. 3 Incorrect ---------------------------- 4. 4 Correct On the seventh day, all three cells in the 4th row are flooded. No other row is completely flooded at this point. ---------------------------- --------------------------------------------- ## Question 3 What will be the last day where we can still cross the matrix, from top to bottom, if the following values are given as input? $rows = 3$ $cols = 3$ $water\_cells = [~[3, 2], ~[1, 3], ~[2, 2], ~[3, 1], ~[1, 1], ~[1, 2], ~[2, 3], ~[3, 3], ~[2, 1]]~$ ### Options 1. 9 Incorrect ---------------------------- 2. 6 Incorrect ---------------------------- 3. 3 Correct The last day where it is possible to cross the matrix from top to bottom is on day 3. * On day 1, as per the `water_cells` array, the cell in the 3rd row and the 2nd column, [3, 2], will get flooded, but we can cross the matrix from top to bottom. * On day 2, the cell in the 1st row and the 3rd column, [1, 3], will get flooded, but we can cross the matrix from top to bottom. * On day 3, the cell in the 2nd row and the 2nd column, [2, 2], will get flooded, but we can cross the matrix from top to bottom. * On day 4, the cell in the 3rd row and the 1st column, [3, 1], will get flooded, so now we can't cross the matrix from top to bottom. ---------------------------- 4. 1 Incorrect ---------------------------- --------------------------------------------- ## Question 4 What will be the last day where we can still cross the matrix, from top to bottom, if the following values are given as input? $rows = 2$ $cols = 4$ $water\_cells = [~[1, 2], ~[1, 4], ~[2, 1], ~[1, 1], ~[2, 4], ~[1, 3], ~[2, 3], ~[2, 2]~]$ ### Options 1. 5 Correct On the 1st day, cell [1, 2] will be filled with water, and we can move from top to the bottom row. On the 2nd day, cell [1, 4] will be filled with water, and we can move from top to the bottom row. On the 3rd, 4th, and 5th days, cells [2, 1], [1, 1], and [2, 4] will be filled and we can still move from top to the bottom row. However, on the 6th day, cell [1, 3] will be filled with water and it is not possible to move from top to the bottom row. Therefore, 5 was the last day where we could still cross. ---------------------------- 2. 6 Incorrect ---------------------------- 3. 7 Incorrect ---------------------------- 4. 8 Incorrect ---------------------------- ---------------------------------------------