Skip to content

Commit 5a6e8ad

Browse files
committed
d9 p1 sol
1 parent 0e9ac03 commit 5a6e8ad

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

2025/Day_09/part_1.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
88
// = Copyright (c) NullDev = //
99
// ========================= //
1010

11-
const INPUT = String(fs.readFileSync(path.join(__dirname, "input.txt"))).trim().split("\n");
11+
const INPUT = String(fs.readFileSync(path.join(__dirname, "input.txt")))
12+
.trim().split(/\s+/).map(l => l.split(",").map(Number));
1213

1314
const pStart = performance.now();
1415

15-
//
16-
// YOUR CODE HERE
17-
//
18-
const result = "...";
16+
const res = INPUT.flatMap((pA, iA) =>
17+
INPUT.slice(iA + 1).map((
18+
pB, _, __, [x1, y1] = pA, [x2, y2] = pB,
19+
) => ((Math.abs(x1 - x2) + 1) * (Math.abs(y1 - y2) + 1))),
20+
).reduce((maxA, curA) => Math.max(maxA, curA), 0);
1921

2022
const pEnd = performance.now();
2123

22-
console.log("<DESCRIPTION>: " + result);
24+
console.log("LARGEST AREA OF RECTANGLES: " + res);
2325
console.log(pEnd - pStart);

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ I also tried to experiment with a couple of different things:
153153
- One-Liner in both [Day_05/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2025/Day_05/part_1.js) and [Day_05/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2025/Day_05/part_2.js)
154154
- Very cursed One-Liner in both [Day_06/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2025/Day_06/part_1.js) and [Day_06/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2025/Day_06/part_2.js)
155155
- One-Liner in both [Day_08/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2025/Day_08/part_1.js) and [Day_08/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2025/Day_08/part_2.js)
156+
- One-Liner in [Day_09/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2025/Day_09/part_1.js)
156157

157158
<hr>
158159

0 commit comments

Comments
 (0)