Skip to content

Commit

Permalink
wip: create src/29751.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lumirlumir committed Dec 8, 2024
1 parent b557abd commit 844a14b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/solutions-readline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "0.0.0",
"scripts": {
"start:1000": "node src/1000",
"start:1001": "node src/1001"
"start:1001": "node src/1001",
"start:29751": "node src/29751"
}
}
26 changes: 26 additions & 0 deletions examples/solutions-readline/src/29751.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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 [W, H] = inputFile
.trim()
.split(' ')
.map(val => Number(val));

const width = (W * H) / 2;

log(width.toFixed(1));
}

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

0 comments on commit 844a14b

Please sign in to comment.