0
Hello! I started to solve problems of the Urionlinejudge platform and in the first challenge I already had doubts about the solution with Node.js. The problem only asks to insert two integers (one in each row) and the script must return their sum in the requested format. The solution was accepted on the platform, however when I run the script on my terminal no output is ever generated. Why might this be happening? Follows the script:
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var a = parseInt(lines.shift());
var b = parseInt(lines.shift());
var x = a + b;
console.log('X = ' + x);
Hey, Diogo. What’s up? Passing some file as the first argument of the readFileSync function the script works, but I could not yet make the script run just by inserting data into the terminal. I would like to make the above script work haha. Using the 'readline-Sync' library I was able to easily solve the problem. It is not possible to make changes to the stdin file, because it is a representation of the default input offered by the user, which in this case is the keyboard. Still the script doesn’t work. I find it very strange.
– V. Rodrigues