function scenicScore(row, col, grid) {
const tree = grid[row][col];
const [l, r] = lr(row, col, grid);
const [u, d] = ud(row, col, grid);
const viewDist = (trees) => {
const lowerThan = AOC.takeWhile((t) => tree > t, trees);
return lowerThan.length + (trees[lowerThan.length] ? 1 : 0);
};
return AOC.product([viewDist(u), viewDist(l), viewDist(r), viewDist(d)]);
}