Skip to content

Commit 7352bc3

Browse files
committed
Merge branch 'main' of https://github.com/front-studium/solveit into sujin
2 parents d412954 + d2f5a4d commit 7352bc3

File tree

8 files changed

+73
-1
lines changed

8 files changed

+73
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function solution(str1, str2) {
2+
if(typeof str1 !== 'string' || typeof str2 !== 'string') throw new Error('문자를 입력해주세요.');
3+
const result = str1.indexOf(str2) !== -1 ? 1 : 2;
4+
5+
return result;
6+
}

Insung-Jo/level_0/짝수의 합.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function solution(n) {
2+
if(typeof n !== 'number') throw new Error('정수를 입력해주세요.');
3+
if(n <= 1) return 0;
4+
5+
let result = 0;
6+
7+
for(let i = 2; i <= n; i+=2){
8+
result += i;
9+
}
10+
11+
return result;
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function solution(str1, str2) {
2+
3+
return str1.includes(str2) ? 1 : 2;
4+
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function solution(n) {
2+
var answer = 0;
3+
4+
for(let i = 0; i <= n; i++){
5+
if(i%2 === 0){
6+
answer += i;
7+
}
8+
}
9+
10+
return answer;
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function solution(str1, str2) {
2+
for(let i=0; i<= str1.length - str2.length; i++) {
3+
let contain = true;
4+
for(let j=0; j<str2.length; j++) {
5+
if (str1[i+j] !== str2[j]) {
6+
contain = false;
7+
break;
8+
}
9+
}
10+
if (contain) return 1;
11+
}
12+
return 2;
13+
}
14+
15+
// 다른 풀이
16+
// function solution(str1, str2) {
17+
// return str1.includes(str2) ? 1 : 2;
18+
// }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function solution(n) {
2+
let sum = 0;
3+
for(let i=1; i<=n; i++) {
4+
if (i%2===0) {
5+
sum += i;
6+
}
7+
}
8+
return sum;
9+
}
10+
11+
// 다른 풀이
12+
// function solution(n) {
13+
// var half = Math.floor(n/2);
14+
// return half*(half+1);
15+
// }

yujin-level0/Week9/각도기.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ function solution(angle) {
88
} else if (angle === 180) {
99
return 4;
1010
}
11-
}
11+
}
12+
13+
// 다른 풀이
14+
// function solution(angle) {
15+
// return [0, 90, 91, 180].filter(x => angle>=x).length;
16+
// }

0 commit comments

Comments
 (0)