mirror of
https://github.com/ershisan99/advent-of-code.git
synced 2025-12-17 12:32:57 +00:00
2024 day 11 wip
This commit is contained in:
35
2024/day-11/day11.ts
Normal file
35
2024/day-11/day11.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Worker } from "node:worker_threads";
|
||||
|
||||
export async function part1(input: string) {
|
||||
const lines = input.split("\n");
|
||||
const line = lines[0];
|
||||
const stones = line.split(" ").map(Number);
|
||||
stones.length = 1;
|
||||
// for (let i = 0; i < 75; i++) {
|
||||
// console.log(i);
|
||||
// stones = blink(stones);
|
||||
// }
|
||||
let final = 0;
|
||||
await Promise.all(
|
||||
stones.map(async (stone) => {
|
||||
const sum = (await new Promise((res) => {
|
||||
const worker = new Worker("./2024/day-11/workers.ts", {
|
||||
workerData: stone,
|
||||
});
|
||||
|
||||
worker.on("message", (result) => {
|
||||
res(result);
|
||||
});
|
||||
})) as number;
|
||||
final += sum;
|
||||
}),
|
||||
);
|
||||
|
||||
return final;
|
||||
}
|
||||
|
||||
export function part2(input: string) {
|
||||
const lines = input.split("\n");
|
||||
const final = 0;
|
||||
return final;
|
||||
}
|
||||
Reference in New Issue
Block a user