프로그래머스 - 바탕화면 정리
part31. 바탕화면 정리
js ver 1.0
function solution(wallpaper) {
// wallpaper.reduce((acc, [...row], i) => {
const {x, y} = wallpaper.reduce((acc, row, i) => {
// row.forEach((el, j) => {
row.split('').forEach((el, j) => {
if (el == '#') {
acc.x.push(i);
acc.y.push(j);
}
})
return acc;
}, {x: [], y: []})
return [Math.min(...x), Math.min(...y), Math.max(...x) + 1, Math.max(...y) + 1];
}