day3_part2_result = {
const w = day3_input.indexOf("\n") + 1;
const input = day3_input;
const digit = i => `${+input[i]}` === input[i];
const seek = (i) => {
if(!digit(i)) return;
let i0 = i, i1 = i;
while(digit(i0 - 1)) i0--;
while(digit(++i1));
return [input.slice(i0, i1), i0, i1];
};
const seekRow = (i0, i1) => {
const m = [];
for(let i = i0, n; i <= i1; i++) if(n = seek(i)) m.push(n), i = n[2];
return m;
}
return Array.from(input.matchAll(/[*]/g), ({index: i}) => {
const [a, b, c] = [
...seekRow(i - 1, i - 1),
...seekRow(i + 1, i + 1),
...seekRow(i - 1 - w, i + 1 - w),
...seekRow(i - 1 + w, i + 1 + w),
];
return b && !c ? a[0] * b[0] : 0;
}).reduce((s, v) => s + v);
}