Skip to content

Commit 657d611

Browse files
authored
Merge pull request #502 from egg-silver/main
[이지은] 60차 라이브 코테 제출
2 parents 857dc94 + fa27577 commit 657d611

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

live5/test60/문제1/이지은.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n');
6+
7+
function solution(input) {
8+
const n = Number(input[1]);
9+
const inputs = input.slice(2);
10+
11+
let left = input[0].split('');
12+
let right = [];
13+
14+
for (let i = 0; i < n; i++) {
15+
if (inputs[i] === 'L') {
16+
if (left.length !== 0) {
17+
right.push(left.pop());
18+
}
19+
// console.log('L : 커서 왼쪽이동', left, right);
20+
} else if (inputs[i] === 'D') {
21+
if (right.length !== 0) {
22+
left.push(right.pop());
23+
}
24+
// console.log('D : 커서 오른쪽이동', left, right);
25+
} else if (inputs[i] === 'B') {
26+
if (left.length !== 0) {
27+
left.pop();
28+
}
29+
// console.log('B : 왼쪽 삭제', left, right);
30+
} else {
31+
left.push(inputs[i].split(' ')[1]);
32+
// console.log('P : 왼쪽 추가', left, right);
33+
}
34+
}
35+
// console.log(left, right);
36+
37+
return left.join('').trim() + right.reverse().join('').trim();
38+
}
39+
40+
console.log(solution(input));

live5/test60/문제2/이지은.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n');
6+
7+
function solution(input) {
8+
const [n, game] = input[0].split(' ');
9+
const games = input.slice(1);
10+
11+
let names = new Set();
12+
for (let i = 0; i < n; i++) {
13+
names.add(games[i]);
14+
}
15+
if (game === 'Y') {
16+
return names.size;
17+
}
18+
if (game === 'F') {
19+
return Math.floor(names.size / 2);
20+
} else {
21+
return Math.floor(names.size / 3);
22+
}
23+
}
24+
25+
console.log(solution(input));

live5/test60/문제3/이지은.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function solution(s) {
2+
let zero = 0;
3+
let count = 0;
4+
let newS = [];
5+
6+
removeZero(s);
7+
8+
function removeZero(s) {
9+
// console.log('s', s);
10+
newS = [];
11+
12+
s.split('').map((el) => (el == '0' ? zero++ : newS.push(el)));
13+
count++;
14+
// console.log('zero의 개수', zero, '0제거한 배열->', newS);
15+
}
16+
while (newS.length !== 1) {
17+
let c = newS.length;
18+
newS = c.toString(2);
19+
removeZero(newS.toString());
20+
}
21+
22+
return [count, zero];
23+
}
24+
25+
console.log(solution('110010101001'));

0 commit comments

Comments
 (0)