TÓPICO
Wrong answer, mas tno uDebug da certo
yurinekan perguntou 3 years ago
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var a, last = 0;
while (a != 0) {
a = lines.shift();
if (a > 0) {
var arrDivided = []
for (let i = 0; i < a; i++) {
arrDivided.push((lines.shift()))
}
alignRight(arrDivided)
}
}
function alignRight(arr) {
var maxCharacteres = [];
var newArr = [];
if(last == 1)
console.log("")
last = 1;
for (let i = 0; i < arr.length; i++) {
maxCharacteres.push(arr[i].length)
}
maxCharacteres = Math.max.apply(null, maxCharacteres)
for (let i = 0; i < arr.length; i++) {
if (arr[i].length >= maxCharacteres)
newArr.push(arr[i])
if (arr[i].length < maxCharacteres) {
let space = "";
for (let j = 0; j < maxCharacteres - arr[i].length; j++)
space += '\xa0'
newArr.push(arr[i].substr(0, 0) + space + arr[i].concat());
}
}
for(let i = 0; i < arr.length; i++) {
console.log(newArr[i])
}
}
Este tópico ainda não foi respondido. Seja o primeiro!