Skip to content

Commit 0ded681

Browse files
authored
20251026 (#22)
* add: 보이는 학생 * add: 가위바위보
1 parent b4af8b5 commit 0ded681

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function solution(arr) {
2+
let results = [arr[0]];
3+
4+
for (let i = 1; i < arr.length; i++) {
5+
if (results[results.length - 1] < arr[i]) {
6+
results.push(arr[i]);
7+
}
8+
}
9+
10+
return results.length;
11+
}
12+
13+
console.log(solution([130, 135, 148, 140, 145, 150, 150, 153])); // 5
14+
console.log(solution([120, 125, 152, 130, 135, 135, 143, 127, 160])); // 4
15+
console.log(solution([150, 135, 145, 147, 148])); // 3
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function solution(a, b) {
2+
const result = [];
3+
4+
for (let i = 0; i < a.length; i++) {
5+
if (a[i] === b[i]) result.push('D');
6+
else if (a[i] === 1 && b[i] === 3) result.push('A');
7+
else if (a[i] === 2 && b[i] === 1) result.push('A');
8+
else if (a[i] === 3 && b[i] === 2) result.push('A');
9+
else result.push('B');
10+
}
11+
12+
return result.join(' ');
13+
}
14+
15+
console.log(solution([2, 3, 3, 1, 3], [1, 1, 2, 2, 3])); // A B A B D

0 commit comments

Comments
 (0)