function enhancePixel(row, col, grd, alg, isEven) {
const dflt = isEven ? "0" : alg[0];
const cellAt = (r, c) =>
r < 0 || c < 0 || r >= grd.length || c >= grd[0].length ? dflt : grd[r][c];
const window =
cellAt(row - 1, col - 1) +
cellAt(row - 1, col) +
cellAt(row - 1, col + 1) +
cellAt(row, col - 1) +
cellAt(row, col) +
cellAt(row, col + 1) +
cellAt(row + 1, col - 1) +
cellAt(row + 1, col) +
cellAt(row + 1, col + 1);
return alg[parseInt(window, 2)];
}