Skip to content

Instantly share code, notes, and snippets.

@misterpoloy
Created January 11, 2019 18:40
Show Gist options
  • Save misterpoloy/3e6502fa3f60642a88ab0cbfcfb719ec to your computer and use it in GitHub Desktop.
Save misterpoloy/3e6502fa3f60642a88ab0cbfcfb719ec to your computer and use it in GitHub Desktop.
process.stdin.resume();
process.stdin.setEncoding("ascii");
var input = "";
process.stdin.on("data", function (chunk) {
input += chunk;
});
process.stdin.on("end", function () {
// now we can read/parse input
let response = false;
// Check elements of input
if (!input) return response;
const elements = input.split('\n');
const array = elements[1].split(" ");
const target = parseInt(elements[2]);
let i = 0;
while (i < array.length && response === false) {
array.forEach(number => {
// Check parse vars to target
if ((parseInt(array[i]) + parseInt(number)) === target) {
response = 'True';
}
});
i++;
}
console.log(response);
return response;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment