input: Write a function to solve a system of linear equations using Gaussian elimination.
  assert optimize_linear_equations([[2, 1, 1, 10], [1, 3, 2, 13], [1, 1, 3, 12]]) == [1.0, 2.0, 3.0]
  assert optimize_linear_equations([[1, 1, 1, 6], [0, 2, 5, -4], [2, 5, -1, 27]]) == [5.0, 3.0, -2.0]
  assert optimize_linear_equations([[3, 2, -4, 3], [2, 3, 3, 15], [5, -3, 1, 14]]) == [3.0, 1.0, 2.0]
output: def optimize_linear_equations(matrix):
      n = len(matrix)
      
      for i in range(n):
          max_row = i
          for k in range(i+1, n):
              if abs(matrix[k][i]) > abs(matrix[max_row][i]):
                  max_row = k
          matrix[i], matrix[max_row] = matrix[max_row], matrix[i]
          
          for k in range(i+1, n):
              c = -matrix[k][i] / matrix[i][i]
              for j in range(i, n+1):
                  if i == j:
                      matrix[k][j] = 0
                  else:
                      matrix[k][j] += c * matrix[i][j]
  
      solution = [0 for _ in range(n)]
      for i in range(n-1, -1, -1):
          solution[i] = matrix[i][n] / matrix[i][i]
          for k in range(i-1, -1, -1):
              matrix[k][n] -= matrix[k][i] * solution[i]
  
      return solution