import { loadInput } from "../common.js"; // const input = loadInput("./3/test.input", parseInput, true); const input = loadInput(3, parseInput); solve(input); /** * @param {string} memDump */ function parseInput(memDump) { return Array.from(memDump.matchAll(/(mul\(\d{1,3},\d{1,3}\))/g)); } function solve(validInstructions) { let sum = 0; for(const inst of validInstructions) { sum += eval(inst[0]); } console.log("Sum of result of valid instructions:", sum); } function mul(a,b) { return a*b; }