mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-11-15 02:03:49 +00:00
13 lines
379 B
JavaScript
13 lines
379 B
JavaScript
|
import { readFileSync } from "fs";
|
||
|
const t0 = performance.now();
|
||
|
|
||
|
const input = readFileSync("input.txt").toString().split("\n")[0].split(",");
|
||
|
const hashes = input.map((e) =>
|
||
|
e.split("").reduce((a, i) => ((a + i.charCodeAt(0)) * 17) % 256, 0)
|
||
|
);
|
||
|
const sum = hashes.reduce((a, i) => a + i);
|
||
|
console.log(sum);
|
||
|
|
||
|
const t1 = performance.now();
|
||
|
console.log(`Runtime: ${t1 - t0}ms`);
|