had to speedrun that this morning on termux, its not even properly indented
This commit is contained in:
2024-12-03 22:01:30 +01:00
parent 1318a10f15
commit 61d07a8779

21
2024/02/p2/index.js Normal file
View File

@@ -0,0 +1,21 @@
const fs = require('fs');
const readline = require('readline');
async function processLineByLine() {
const fileStream = fs.createReadStream('input.txt');
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
let t = 0
for await (const line of rl) {
let m = line.match(/mul\([0-9]{1,3}, ?[0-9]{1,3}\)/g);
m = m.map(e => e.split('(')[1].split(')')[0].split(','))
.forEach(([a,b]) => t+=-a*-b)
}
console.log(t);
}
processLineByLine();