Skip to content

Instantly share code, notes, and snippets.

@Nusab19
Last active June 25, 2023 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nusab19/c2fba6d26ed2af85291bb7042e5f83e4 to your computer and use it in GitHub Desktop.
Save Nusab19/c2fba6d26ed2af85291bb7042e5f83e4 to your computer and use it in GitHub Desktop.
Take input in NodeJS for Online Judges. This is the long version.
// Credit: Nusab Taha @Nusab19
// Minimized Version: https://gist.github.com/Nusab19/fc8d96ae73a910acb8403758dc41f8c5
// Do not change anything from here....
let _inputData = "";
let _inputArray = [];
let _count = -1;
process.stdin.setEncoding("utf8");
process.stdin.on("data", function (chunk) {
_inputData += chunk;
});
process.stdin.on("end", function () {
_inputArray = _inputData.split("\n");
input();
main();
});
function input() {
let line = _inputArray[_count];
_count++;
return line;
}
// Till here.....
// You need to code everything in this main function.
function main() {
// input function will return a `string` or `undefined`.
// `undefined` means there's no more input left.
let a = input();
let b = input();
let c = input();
console.log(a, b, c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment