Skip to content

Commit 996e839

Browse files
committed
refactor(2025/day/7): renaming some variables
1 parent 69d3e3e commit 996e839

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

2025/day/7/part/2/solve.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
export default function solve(input: string) {
22
const rows = input.split("\n").map((line) => Array.from(line));
3-
const beamColumnIndexes = new Map([[rows[0].indexOf("S"), 1]]);
3+
const timelineCounts = new Map([[rows[0].indexOf("S"), 1]]);
44
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
5-
for (const [beamColumnIndex, timelineCount] of beamColumnIndexes) {
5+
for (const [beamColumnIndex, timelineCount] of timelineCounts) {
66
if (rows[rowIndex + 1]?.[beamColumnIndex] !== "^") continue;
7-
beamColumnIndexes.delete(beamColumnIndex);
7+
timelineCounts.delete(beamColumnIndex);
88
for (const direction of [-1, 1]) {
99
const splitColumnIndex = beamColumnIndex + direction;
10-
const prevTimelineCount = beamColumnIndexes.get(splitColumnIndex);
10+
const prevTimelineCount = timelineCounts.get(splitColumnIndex);
1111
const nextTimelineCount = (prevTimelineCount ?? 0) + timelineCount;
12-
beamColumnIndexes.set(splitColumnIndex, nextTimelineCount);
12+
timelineCounts.set(splitColumnIndex, nextTimelineCount);
1313
}
1414
}
1515
}
16-
return beamColumnIndexes.values()
17-
.reduce((sum, timelineCount) => sum + timelineCount, 0);
16+
return timelineCounts.values().reduce((sum, count) => sum + count, 0);
1817
}

0 commit comments

Comments
 (0)