2023-10-23 23:16:24 +02:00
|
|
|
import readline from "node:readline"
|
2023-05-21 12:02:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {string} string
|
|
|
|
* @param {number} resultLength
|
|
|
|
* @param {string} padString
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
const leftPad = (string, resultLength, padString) => {
|
|
|
|
resultLength = resultLength - string.length
|
|
|
|
if (resultLength <= 0) {
|
|
|
|
return string
|
|
|
|
}
|
2023-10-23 23:16:24 +02:00
|
|
|
let pad = ""
|
2023-05-21 12:02:22 +02:00
|
|
|
while (resultLength !== 0) {
|
|
|
|
if (resultLength & 1) {
|
|
|
|
pad += padString
|
|
|
|
}
|
|
|
|
resultLength >>= 1
|
|
|
|
if (resultLength) {
|
|
|
|
padString += padString
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pad + string
|
|
|
|
}
|
|
|
|
|
|
|
|
const solution = () => {
|
|
|
|
console.log(leftPad(input[0], Number(input[1]), input[2]))
|
|
|
|
}
|
|
|
|
|
|
|
|
const input = []
|
|
|
|
const readlineInterface = readline.createInterface({
|
|
|
|
input: process.stdin,
|
2023-10-23 23:16:24 +02:00
|
|
|
output: process.stdout,
|
2023-05-21 12:02:22 +02:00
|
|
|
})
|
2023-10-23 23:16:24 +02:00
|
|
|
readlineInterface.on("line", (value) => {
|
2023-05-21 12:02:22 +02:00
|
|
|
input.push(value)
|
|
|
|
})
|
2023-10-23 23:16:24 +02:00
|
|
|
readlineInterface.on("close", solution)
|