Skip to content

Commit

Permalink
wip: create src/1001.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lumirlumir committed Dec 8, 2024
1 parent 69ad5cd commit b557abd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/solutions-readline/src/1001.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { createInterface } = require('node:readline');
const { stdin: input, stdout: output } = require('node:process');
const { EOL } = require('node:os');
const { log } = require('node:console');

const rl = createInterface({ input, output });

let inputFile = '';

// eslint-disable-next-line no-shadow
function solution(inputFile) {
const [a, b] = inputFile
.trim()
.split(' ')
.map(val => Number(val));

log(a - b);
}

rl.on('line', line => {
inputFile += `${line}${EOL}`;
}).on('close', () => {
solution(inputFile);
});

0 comments on commit b557abd

Please sign in to comment.