Skip to content

Instantly share code, notes, and snippets.

@Nusab19
Last active June 25, 2023 18:11
Show Gist options
  • Save Nusab19/fc8d96ae73a910acb8403758dc41f8c5 to your computer and use it in GitHub Desktop.
Save Nusab19/fc8d96ae73a910acb8403758dc41f8c5 to your computer and use it in GitHub Desktop.
Take input in NodeJS for Online Judges. This is the short version.
// Credit: Nusab Taha @Nusab19
// Gist: https://gist.github.com/Nusab19/fc8d96ae73a910acb8403758dc41f8c5
let _inputData="",_inputArray=[],_count=-1;function input(){let n=_inputArray[_count];return _count++,n}process.stdin.setEncoding("utf8"),process.stdin.on("data",(function(n){_inputData+=n})),process.stdin.on("end",(function(){_inputArray=_inputData.split("\n"),input(),main()}));
// 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