const solution = (brown, yellow) => {
const total = brown + yellow;
let col = Math.floor(Math.sqrt(total));
let row;
while (col > 2) {
if (total % col == 0) {
row = total / col;
if ((row + col) * 2 - 4 == brown) {
return [row, col];
}
}
col--;
}
};