export function flatten(grid: T[][]) { const flattened = [] as T[]; for (const row of grid) { flattened.push(...row); } return flattened; }