Skip to content

Commit ed51239

Browse files
authored
๐Ÿ”€: 2750 retry(1) (#12)
* ๐Ÿšฉ: ๋ฌธ์ œ๋ฅผ ํ’€๊ธฐ์œ„ํ•œ ์„ธํŒ… * ๐Ÿšฉ: PR ํ…œํ”Œ๋ฆฟ ์ƒ์„ฑ ๋ฌธ์ œ๋กœ ํŒŒ์ผ ์‚ญ์ œ * ๐Ÿšฉ: bubble ์ •๋ ฌ ์ ์šฉ ๋ฐ ์ •๋ ฌ ํ™•์ธ * ๐Ÿšฉ: ๋ฐฐ์—ด ์ค‘๋ณต์ œ๊ฑฐ ๋กœ์ง ๊ตฌํ˜„ ์˜ค๋‹ต * ๐ŸŒฑ : PR ํ…œํ”Œ๋ฆฟ ์žฌ์ƒ์„ฑ * ๐Ÿ›: sort์™€ filter ๊ทธ๋ฆฌ๊ณ  indexOf ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ ํ•ด๊ฒฐ ์‹œ๋„, ์˜ค๋‹ต * ๐Ÿ›: shift์™€ trim์„ ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ ํ•ด๊ฒฐ, pop์œผ๋กœ ๋ฌธ์ œ๋ฅผ ์‹œ๋„ ํ–ˆ์œผ๋‚˜ ์˜ค๋‹ต ์™œ์ธ์ง€ ์•„์ง ๋ช…ํ™•ํ•˜์ง€ ์•Š๋‹ค. * ๐Ÿšฉ: ์ฃผ์„์ œ๊ฑฐ
1 parent 440863b commit ed51239

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed
Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
let path = require('path');
22
let inputPath = path.join(__dirname, '/dev/stdin'); // __dirname์€ ํ˜„์žฌ ์Šคํฌ๋ฆฝํŠธ์˜ ๋””๋ ‰ํ† ๋ฆฌ ์ ˆ๋Œ€๊ฒฝ๋กœ
3-
let input = require('fs').readFileSync(inputPath).toString().split('\n');
3+
let input = require('fs').readFileSync(inputPath).toString().trim().split('\n');
44
//let input = require('fs').readFileSync('/dev/stdin').toString().split('\n'); //๋ฐฑ์ค€ ์ œ์ถœ
55
console.log(input);
6-
7-
let arr = [];
8-
for (let i = 0; i < input.length; i++) {
9-
if (!arr.includes(input[i])) {
10-
arr.push(input[i]);
11-
}
12-
}
13-
14-
for (let i = 0; i < arr.length; i++) {
15-
for (let j = 0; j < arr.length; j++) {
16-
//for (let j = 0; j < arr.length - 1 - i; j++) { // ๋‚ด๋ถ€ ๋ฐ˜๋ณต๋ฌธ์—์„œ ๋น„๊ต ๋ฒ”์œ„ ๊ฐ์†Œ
17-
if (arr[j] > arr[j + 1]) {
18-
[arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
19-
}
20-
}
21-
}
22-
23-
console.log(arr);
24-
arr.forEach(element => console.log(element));
6+
input.shift();
7+
const arr = input.sort((a, b) => a - b); //์•”๋ฌต์ ์œผ๋กœ ์ˆซ์ž๋กœ ํ˜•๋ณ€ํ™˜
8+
arr.forEach(element => console.log(element));

0 commit comments

Comments
ย (0)