input: Write a function to generate an NxN matrix where each element is its linear index.
  assert generate_matrix(2) == [[0, 1], [2, 3]]
  assert generate_matrix(3) == [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
  assert generate_matrix(4) == [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]]
output: def generate_matrix(n):
      return [[i * n + j for j in range(n)] for i in range(n)]