문제
https://www.acmicpc.net/problem/10798
풀이
const words = require("fs").readFileSync("/dev/stdin").toString().trim().split("\n");
const maxLength = Math.max(...words.map(i => i.length));
let vertical = "";
for (let i=0; i<maxLength; i++) {
for (let j=0; j<words.length; j++) {
vertical += words[j][i] || "";
}
}
console.log(vertical);
[손코딩]
[풀이보고 이해한거]
[처음풀이 1]
for(let i = 0; i < input.length; i++) {
for(let j = 0; j < i.length; j++) {
result =+ input[i][j];
}
}
[처음풀이 2]
let result = input.map((v, i) => v = v[i]);
console.log(result);
뭔가 요소 안의 요소에 접근하려고 map을 쓰고싶었는데 잘 안풀림..
map을 이용한 다른풀이
Math.max(...words.map(i => i.length));
에...????