Skip to content

Instantly share code, notes, and snippets.

@gus3inov
Last active September 20, 2022 13:16
Show Gist options
  • Save gus3inov/3a10df2632eecfe4226630db64ae54f6 to your computer and use it in GitHub Desktop.
Save gus3inov/3a10df2632eecfe4226630db64ae54f6 to your computer and use it in GitHub Desktop.
Inputs
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