Skip to content

Commit

Permalink
add (programmers - level2 1문제): js 풀이
Browse files Browse the repository at this point in the history
  • Loading branch information
padosum committed Jan 4, 2023
1 parent 7860629 commit ed82b6f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions programmers/level2/카펫.js
@@ -0,0 +1,16 @@
function solution(brown, yellow) {
let width = 0;
let height = 0;
for (let i = 1; i <= Math.sqrt(yellow); i++) {
if (yellow % i === 0) {
const w = yellow / i;
const h = i;
if ((w + 2) * 2 + h * 2 === brown) {
width = w + 2;
height = h + 2;
}
}
}

return [width, height];
}

0 comments on commit ed82b6f

Please sign in to comment.