Skip to content

Commit fd99326

Browse files
authored
Merge pull request #139 from front-studium/yujin
`Week31` 문제풀이
2 parents b3c3716 + c389a2a commit fd99326

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function solution(num_list, n) {
2+
return num_list.slice([n - 1]);
3+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function solution(n) {
2+
for (let x = 2; x < n; x++) {
3+
if (n % x === 1) {
4+
return x;
5+
}
6+
}
7+
}
8+
9+
// 다른 풀이
10+
// function solution(n, x = 1) {
11+
// while (x++) {
12+
// if (n % x === 1) {
13+
// return x;
14+
// }
15+
// }
16+
// }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function solution(num_list) {
2+
for (i = 0; i < num_list.length; i++) {
3+
if (num_list[i] < 0) {
4+
return i;
5+
}
6+
}
7+
return -1;
8+
}
9+
10+
// 다른 풀이
11+
// const solution = num_list => num_list.findIndex(v => v < 0)
12+
13+
// function solution(num_list) {
14+
// let a = num_list.filter(c=> {if(c<0) return c})
15+
// return num_list.indexOf(a[0])
16+
// }

0 commit comments

Comments
 (0)