Last active
September 20, 2022 13:16
-
-
Save gus3inov/3a10df2632eecfe4226630db64ae54f6 to your computer and use it in GitHub Desktop.
Inputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require('readline'); | |
const { stdin: input, stdout: output } = require('process'); | |
const getUserInput = () => { | |
return new Promise(resolve => { | |
const rl = readline.createInterface({ input, output, terminal: false }) | |
rl.question('Enter two numbers: ', answer => { | |
const [x, y] = answer.split(' ') | |
resolve([Number(x), Number(y)]); | |
rl.close(); | |
}) | |
}) | |
} | |
async function getStdInputData() { | |
return new Promise(resolve => { | |
const rl = readline.createInterface({ input, output }) | |
const dataList = [] | |
rl.once('line', async answer => { | |
let [count, capacity] = answer.split(' ') | |
count = Number(count) | |
for (let i = 0; i < count; i++) { | |
const [x, y] = await getUserInput(); | |
dataList.push([x, y]); | |
} | |
resolve(dataList) | |
}) | |
}) | |
} | |
async function maxValueOfTheLoot() { | |
const result = await getStdInputData() | |
console.log(result) | |
} | |
maxValueOfTheLoot().then(result => {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment