Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions javascript/source/dev/stdin
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
13
but
i
wont
hesitate
no
more
no
more
it
cannot
wait
im
yours
AABCDD
afzz
09121
a8EWg6
P5h3kx
24 changes: 13 additions & 11 deletions javascript/source/printer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
let path = require('path');
let inputPath = path.join(__dirname, '/dev/stdin'); // __dirname은 현재 스크립트의 디렉토리 절대경로
let input = require('fs').readFileSync(inputPath).toString().trim().split('\n');
//let input = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n'); //백준 제출
input.shift();
let arr = [...new Set(input)];
//sort의 조건을 다는 방법을 더욱 명확히 잡아 볼 것.
let result = arr.sort((a, b) => {
if (a.length === b.length) {
return a.localeCompare(b);
} else {
return a.length - b.length;

//let input = require('fs').readFileSync('/dev/stdin').toString().split('\n'); //백준 제출
// input.forEach(el => console.log(el))
let max = Math.max(...input.map(el => el.length));
let result = "";
for (let i = 0; i < max; i++) {
for (let j = 0; j < input.length; j++) {
if (input[j][i]) {
result += input[j][i];
}
}
});
console.log(result);

result.forEach(element => console.log(element));
}
console.log(result);