Skip to content

Commit cee4b18

Browse files
committed
순서쌍의 갯수(기초)
1 parent 1f6fd0b commit cee4b18

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function solution(dot) {
2+
let answer = 0;
3+
const [x, y] = dot;
4+
5+
const quadrant = [
6+
[1, 1],
7+
[-1, 1],
8+
[-1, -1],
9+
[1, -1],
10+
];
11+
12+
for (let i = 0; i < quadrant.length; i++) {
13+
const [x, y] = quadrant[i];
14+
15+
const newX = x * dot[0];
16+
const newY = y * dot[1];
17+
18+
if (newX > 0 && newY > 0) {
19+
answer = i + 1;
20+
break;
21+
}
22+
}
23+
24+
return answer;
25+
}
26+
27+
console.log(solution([-7, 9]));

0 commit comments

Comments
 (0)