Created
December 4, 2023 12:57
-
-
Save saharshg29/f0c7a8c84782e7afd326972e303aac66 to your computer and use it in GitHub Desktop.
This is a code snippet for competitive programming using js
This file contains hidden or 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
// For reading input from the command line | |
const readline = require('readline'); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
terminal: false | |
}); | |
// Function to solve the problem | |
function solve(input) { | |
console.log("Hello is being called") | |
// Your logic/code to solve the problem goes here | |
// Use console.log() to output the result | |
console.log(input); | |
} | |
// Reading input line by line | |
let input = []; | |
rl.on('line', (line) => { | |
// Split the line into separate values if needed | |
// For example, if input values are separated by spaces | |
input.push(line.split(' ')); // Split by space | |
// If the input values are single integers on each line, use this: | |
// input.push(parseInt(line)); | |
}); | |
// When all input is read | |
rl.on('close', () => { | |
// Call the solve function with the prepared input | |
solve(input); | |
}); | |
// Use ctrl+d to end the input stream |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment