Skip to content

Instantly share code, notes, and snippets.

@ronen-e
Created July 1, 2016 19:12
Show Gist options
  • Select an option

  • Save ronen-e/dd05b82231e85dda44dd4db5bc0b6b1d to your computer and use it in GitHub Desktop.

Select an option

Save ronen-e/dd05b82231e85dda44dd4db5bc0b6b1d to your computer and use it in GitHub Desktop.
A plus B CLI
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (buf) {
var tokens = formatInput(buf);
var a = parseInt(tokens[0]);
var b = parseInt(tokens[1]);
console.log(a+b);
process.exit();
});
function formatInput(input) {
return input.trim()
.replace(/\s+/g, ' ')
.split(' ')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment