Skip to content

Commit 50a4157

Browse files
committed
알고리즘 업데이트
1 parent c4da94f commit 50a4157

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

section1/8.일곱난쟁이.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(arr) {
9+
let sum = arr.reduce((acc, cur) => acc + cur, 0);
10+
11+
for (let i = 0; i < arr.length - 1; i++) {
12+
if (sum - (arr[i] + arr[i + 1]) === 100) {
13+
arr.splice(i, 2);
14+
return arr;
15+
}
16+
}
17+
}
18+
19+
let arr = [20, 7, 23, 19, 10, 15, 25, 8, 13];
20+
console.log(solution(arr));
21+
</script>
22+
</body>
23+
</html>

section1/9.A를 #으로.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s) {
9+
return s.replaceAll("A", "#");
10+
//return s.replace(/A/g,"#")
11+
}
12+
13+
let str = "BANANA";
14+
console.log(solution(str));
15+
</script>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)