Last active
May 23, 2021 14:05
-
-
Save ezemery/eefc41cb6679b6f4b990e30142d96662 to your computer and use it in GitHub Desktop.
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
function readInput() { | |
const readline = require('readline') | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
}) | |
let problem = { | |
T: 0, | |
testCases: [] | |
} | |
rl.on('line', function (line) { | |
// TODO: Process input | |
if (problem.T === 0) { | |
// Get number of test cases from first line | |
problem.T = Number(line) | |
} else { | |
//the code below is used to read multiple lines consisting or strings and number, please change according to input | |
let previousLine = ""; | |
if (!previousLine) { | |
// no previous line to compare to, so just remember this line | |
previousLine = line; | |
} else { | |
if(!parseInt(line)){ | |
[a,b] = previousLine.split(" "); | |
problem.testCases.push([Number(a), Number(b),line]) | |
} | |
previousLine = line; | |
} | |
} | |
}).on('close', () => { | |
// Finished processing input, now solve question | |
solveProblem(problem.testCases) | |
process.exit() | |
}) | |
} | |
const solve = (array) => { | |
return array; | |
} | |
const solveProblem = (cases) => { | |
for (let index = 0; index < cases.length; index++) { | |
const result = solve(cases[index]) | |
console.log(`Case #${index + 1}: ${result}`) | |
} | |
} | |
readInput() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment