Created
January 19, 2022 12:58
-
-
Save akashvaghela09/f3f4bc3c9f7629b7e3369bdf9bd92691 to your computer and use it in GitHub Desktop.
JavaScript Boilerplate code for DSA
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
function runProgram(input) { | |
// Write code here | |
input = input.trim().split('\n') | |
let arr = input[0].trim().split(" ").map(Number) | |
console.log(arr[0] + arr[1]); | |
} | |
if (process.env.USER === "akash") { | |
runProgram(`5 10`); | |
} else { | |
process.stdin.resume(); | |
process.stdin.setEncoding("ascii"); | |
let read = ""; | |
process.stdin.on("data", function (input) { | |
read += input; | |
}); | |
process.stdin.on("end", function () { | |
read = read.replace(/\n$/, ""); | |
read = read.replace(/\n$/, ""); | |
runProgram(read); | |
}); | |
process.on("SIGINT", function () { | |
read = read.replace(/\n$/, ""); | |
runProgram(read); | |
process.exit(0); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment