[프로그래머스 | 자바스크립트] 안전지대
솔루션 function solution(board) { const isBombNearby = (r, c) => { const nearby = [ [-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1], ]; const isInBoard = (r, c) => r >= 0 && r = 0 && c isInBoard(r + dR, c + dC) && board[r + dR][c + dC] === 1 ); }; let answer = 0; for (let r = 0; r < board.length; r++) { for ..
- 프로그래머스(Javascript)/Level 0
- · 2023. 4. 16.
[프로그래머스 | 자바스크립트] 외계어 사전
솔루션 const solution = (spell, dic) => { const sort = (str) => [...str].sort((a, b) => (a sort(dic) === sort(spell.join(""))) ? 1 : 2; console.log(answer); return answer; }; solution(["p", "o", "s"], ["sod", "eocd", "qixm", "adio", "soo"]); solution(["z", "d", "x"], ["def", "dww", "dzx", "loveaw"]); solution(["s", "o", "m", "d..
- 프로그래머스(Javascript)/Level 0
- · 2023. 3. 3.