Compare commits

...

4 Commits

Author SHA1 Message Date
35a96647a5 init d16p1 2024-01-10 20:22:12 +01:00
cbd3a2929b clean up: formatting 2024-01-10 20:02:15 +01:00
138b4e2944 init d15p2 2023-12-15 20:38:40 +01:00
d6d3a06b85 calc hashes, sum up 2023-12-15 20:38:30 +01:00
13 changed files with 432 additions and 298 deletions

View File

@ -1,38 +1,38 @@
import { readFileSync } from "fs"; import { readFileSync } from "fs";
const t0 = performance.now(); const t0 = performance.now();
const input = readFileSync("input.txt") const input = readFileSync("input.txt")
.toString() .toString()
.split(/\r*\n/) .split(/\r*\n/)
.filter((e) => e.length > 0) .filter((e) => e.length > 0)
.map((e) => e.split("")); .map((e) => e.split(""));
const expand = (arr) => const expand = (arr) =>
arr.reduce( arr.reduce(
(a, i) => [ (a, i) => [
...a, ...a,
...(i.some((e) => e !== ".") ? [i] : [i, Array(i.length).fill(".")]), ...(i.some((e) => e !== ".") ? [i] : [i, Array(i.length).fill(".")]),
], ],
[] []
); );
const flip = (current) => const flip = (current) =>
Array.from({ length: current[0].length }, (_, x) => Array.from({ length: current[0].length }, (_, x) =>
Array.from({ length: current.length }, (_, y) => current[y][x]) Array.from({ length: current.length }, (_, y) => current[y][x])
); );
const universe = flip(expand(flip(expand(input)))); const universe = flip(expand(flip(expand(input))));
const galaxies = universe const galaxies = universe
.map((a, y) => a.map((b, x) => ({ s: b, x, y })).filter((b) => b.s === "#")) .map((a, y) => a.map((b, x) => ({ s: b, x, y })).filter((b) => b.s === "#"))
.filter((e) => e.length > 0) .filter((e) => e.length > 0)
.reduce((a, i) => [...a, ...i], []); .reduce((a, i) => [...a, ...i], []);
const distances = galaxies.map((c, i) => const distances = galaxies.map((c, i) =>
galaxies.reduce( galaxies.reduce(
(a, n, j) => a + (j > i ? Math.abs(c.x - n.x) + Math.abs(c.y - n.y) : 0), (a, n, j) => a + (j > i ? Math.abs(c.x - n.x) + Math.abs(c.y - n.y) : 0),
0 0
) )
); );
const sum = distances.reduce((a, i) => a + i); const sum = distances.reduce((a, i) => a + i);
console.log(sum); console.log(sum);
const t1 = performance.now(); const t1 = performance.now();
console.log(`Runtime: ${t1 - t0}ms`); console.log(`Runtime: ${t1 - t0}ms`);

View File

@ -1,44 +1,44 @@
import { readFileSync } from "fs"; import { readFileSync } from "fs";
const t0 = performance.now(); const t0 = performance.now();
const input = readFileSync("input.txt") const input = readFileSync("input.txt")
.toString() .toString()
.split(/\r*\n/) .split(/\r*\n/)
.filter((e) => e.length > 0) .filter((e) => e.length > 0)
.map((a, j) => a.split("").map((b, i) => ({ s: b, x: i, y: j }))); .map((a, j) => a.split("").map((b, i) => ({ s: b, x: i, y: j })));
const expand = (arr) => { const expand = (arr) => {
let expansion = 0; let expansion = 0;
return arr.map((a) => { return arr.map((a) => {
const c = !a.some((b) => b.s !== "."); const c = !a.some((b) => b.s !== ".");
if (c) expansion += 999999; if (c) expansion += 999999;
return a.map((b) => { return a.map((b) => {
const { s, x, y } = b; const { s, x, y } = b;
return { s, x, y: y + expansion }; return { s, x, y: y + expansion };
}); });
}); });
}; };
const flip = (current) => const flip = (current) =>
Array.from({ length: current[0].length }, (_, cx) => Array.from({ length: current[0].length }, (_, cx) =>
Array.from({ length: current.length }, (_, cy) => { Array.from({ length: current.length }, (_, cy) => {
const { s, x, y } = current[cy][cx]; const { s, x, y } = current[cy][cx];
return { s, x: y, y: x }; return { s, x: y, y: x };
}) })
); );
const universe = flip(expand(flip(expand(input)))); const universe = flip(expand(flip(expand(input))));
const galaxies = universe const galaxies = universe
.map((a) => a.filter((b) => b.s === "#")) .map((a) => a.filter((b) => b.s === "#"))
.filter((e) => e.length > 0) .filter((e) => e.length > 0)
.reduce((a, i) => [...a, ...i], []); .reduce((a, i) => [...a, ...i], []);
const distances = galaxies.map((c, i) => const distances = galaxies.map((c, i) =>
galaxies.reduce( galaxies.reduce(
(a, n, j) => a + (j > i ? Math.abs(c.x - n.x) + Math.abs(c.y - n.y) : 0), (a, n, j) => a + (j > i ? Math.abs(c.x - n.x) + Math.abs(c.y - n.y) : 0),
0 0
) )
); );
const sum = distances.reduce((a, i) => a + i); const sum = distances.reduce((a, i) => a + i);
console.log(sum); console.log(sum);
const t1 = performance.now(); const t1 = performance.now();
console.log(`Runtime: ${t1 - t0}ms`); console.log(`Runtime: ${t1 - t0}ms`);

View File

@ -1,140 +1,140 @@
..#............................#....................................................................................#..........#........#... ..#............................#....................................................................................#..........#........#...
..........#.........................................#....................................................................................... ..........#.........................................#.......................................................................................
...................#..........................................................................#............................................. ...................#..........................................................................#.............................................
.....................................................................................#.............................................#........ .....................................................................................#.............................................#........
.......#.......#.............#..........#......#...................#.....#.................................................................. .......#.......#.............#..........#......#...................#.....#..................................................................
................................................................................#..................#..............#......................... ................................................................................#..................#..............#.........................
....................................#....................................................................................................... ....................................#.......................................................................................................
...........#...................................................................................#......................................#..... ...........#...................................................................................#......................................#.....
.......................................................................................................................#.........#.......... .......................................................................................................................#.........#..........
.....................#.................................................#...................#.................#..............#............... .....................#.................................................#...................#.................#..............#...............
....#...........................................#...............#........................................................................... ....#...........................................#...............#...........................................................................
.........................#.......................................................................#.......................................... .........................#.......................................................................#..........................................
...................................#......................#.......................................................#.......................#. ...................................#......................#.......................................................#.......................#.
..................#...........................................................#.......................#.................#...........#....... ..................#...........................................................#.......................#.................#...........#.......
..........#........................................................#..........................................#............................. ..........#........................................................#..........................................#.............................
.............................................#.........#.....#.............................................................................. .............................................#.........#.....#..............................................................................
.......................#.....................................................................#..............................#..........#.... .......................#.....................................................................#..............................#..........#....
.............................#.......................................................#...........................#.......................... .............................#.......................................................#...........................#..........................
..#...........#.......................#.....................................#............................................................... ..#...........#.......................#.....................................#...............................................................
...........................................................#.............................................#.................................. ...........................................................#.............................................#..................................
......#..........................................................#......#........................................................#.......... ......#..........................................................#......#........................................................#..........
................................#.........#...........#....................................#........#...................#..................# ................................#.........#...........#....................................#........#...................#..................#
...........................#..................................................#..............................#.............................. ...........................#..................................................#..............................#..............................
..............................................#.................................................#........................................... ..............................................#.................................................#...........................................
.#.................................................................................................................#........................ .#.................................................................................................................#........................
.......................................................................#.................................................................... .......................................................................#....................................................................
...............#.............................................................................................................#..........#... ...............#.............................................................................................................#..........#...
.................................#.............................#............................................#............................... .................................#.............................#............................................#...............................
.....#.................#...................#................................................................................................ .....#.................#...................#................................................................................................
....................................................#...................................................#............#...................... ....................................................#...................................................#............#......................
...........#.....#...................................................................#............................................#......... ...........#.....#...................................................................#............................................#.........
..............................................#...........................................................................#................. ..............................................#...........................................................................#.................
...#.........................#.....................................................................#........................................ ...#.........................#.....................................................................#........................................
.........................................................#...................................#........................................#..... .........................................................#...................................#........................................#.....
.........#....................................................#........#................#.....................#............................. .........#....................................................#........#................#.....................#.............................
........................#..........................................................................................#........................ ........................#..........................................................................................#........................
..............#...................................#............................#.............................................#.....#........ ..............#...................................#............................#.............................................#.....#........
.................................#................................................................#......................................... .................................#................................................................#.........................................
..................#........................#...............#................................#.............#.............................#... ..................#........................#...............#................................#.............#.............................#...
..........#........................................................#............................................................#........... ..........#........................................................#............................................................#...........
..#.....................................................................................#.............................#..................... ..#.....................................................................................#.............................#.....................
..........................#..........#..................................#......................................#...........#................ ..........................#..........#..................................#......................................#...........#................
................................................................#........................................................................... ................................................................#...........................................................................
................#................................#..........................#............................................................... ................#................................#..........................#...............................................................
...........................................#..................................................#.....#.......#............................... ...........................................#..................................................#.....#.......#...............................
..........#............................................#.....................................................................#.............. ..........#............................................#.....................................................................#..............
.......................#....................................#...........................................................#..............#.... .......................#....................................#...........................................................#..............#....
.....#.........................#........#..............................................#.................#........................#......... .....#.........................#........#..............................................#.................#........................#.........
.................#....................................................#............................................#........................ .................#....................................................#............................................#........................
....................................#...............#................................................#...................................... ....................................#...............#................................................#......................................
.........................#........................................#................#.......#...................#............................ .........................#........................................#................#.......#...................#............................
....................................................................................................................................#....... ....................................................................................................................................#.......
...........#...................................#...........................#......................#.........................#..............# ...........#...................................#...........................#......................#.........................#..............#
..................................#......#.................................................................................................. ..................................#......#..................................................................................................
......#....................#.........................#..................................................#................................... ......#....................#.........................#..................................................#...................................
......................#...................................#......#.....#.................................................#.................. ......................#...................................#......#.....#.................................................#..................
..............#..............................................................................#.................#.....................#...... ..............#..............................................................................#.................#.....................#......
............................................................................................................................................ ............................................................................................................................................
#.............................#................#....................................................................#....................#.. #.............................#................#....................................................................#....................#..
............................................................................................................................................ ............................................................................................................................................
........#...........................................#....................................................................................... ........#...........................................#.......................................................................................
...................................................................#..........#..................#.......................................... ...................................................................#..........#..................#..........................................
.....................#............#........#.............................................#............#................#.................... .....................#............#........#.............................................#............#................#....................
................#............................................................................................................#.............. ................#............................................................................................................#..............
...............................................................................................................#...................#........ ...............................................................................................................#...................#........
........................#......#..........................#.....#......#................................................................#... ........................#......#..........................#.....#......#................................................................#...
................................................#..........................................#.............#.................................. ................................................#..........................................#.............#..................................
......................................#..............................................................................#...................... ......................................#..............................................................................#......................
..#.................................................................#.........#............................................................. ..#.................................................................#.........#.............................................................
..........#.....#...............................................................................................#...........#............... ..........#.....#...............................................................................................#...........#...............
.................................#....................................................................#..............................#...... .................................#....................................................................#..............................#......
.....................................................#........................................#........................#.................... .....................................................#........................................#........................#....................
..........................................#..................#............#................................................................. ..........................................#..................#............#.................................................................
......................#...............................................................#..................#.........#............#........... ......................#...............................................................#..................#.........#............#...........
......#........................................................................#............................................................ ......#........................................................................#............................................................
...................................#...................................#..................................................#................. ...................................#...................................#..................................................#.................
...................................................#.........................................#.................#............................ ...................................................#.........................................#.................#............................
...........................#...................................#.....................................................................#...... ...........................#...................................#.....................................................................#......
........................................#................................................................................................... ........................................#...................................................................................................
................#......................................#........................#.........#.....#........................................... ................#......................................#........................#.........#.....#...........................................
...........#......................#.....................................................................#................................... ...........#......................#.....................................................................#...................................
....#....................#...................#...................#................................................#...........#...........#. ....#....................#...................#...................#................................................#...........#...........#.
............................................................................................................................................ ............................................................................................................................................
............................................................................................................................................ ............................................................................................................................................
.....................................#....................................#................................................................. .....................................#....................................#.................................................................
.......................#..................#........#............................#................#.............#............................ .......................#..................#........#............................#................#.............#............................
...............#...............................................#......................#..............................................#...... ...............#...............................................#......................#..............................................#......
............................................................................................................................................ ............................................................................................................................................
.................................#...........#.....................#....................................................#................... .................................#...........#.....................#....................................................#...................
............................................................................................................................................ ............................................................................................................................................
..#........#..........#...............#..................................................................#..........#......................# ..#........#..........#...............#..................................................................#..........#......................#
............................................................#............................#.................................................. ............................................................#............................#..................................................
.................................................................#..........#.................................#.................#........... .................................................................#..........#.................................#.................#...........
.............................#......................#....................................................................................... .............................#......................#.......................................................................................
....#..................................................................................................................................#.... ....#..................................................................................................................................#....
...................#...............#..................................................#....................#................................ ...................#...............#..................................................#....................#................................
.........................................................#......................................#...................#..............#........ .........................................................#......................................#...................#..............#........
.....................................................................#...................................................#.................. .....................................................................#...................................................#..................
........................#...................................................................#..................#............................ ........................#...................................................................#..................#............................
...#.....#...............................#....................#............................................................................. ...#.....#...............................#....................#.............................................................................
................#...............#........................................................................................................... ................#...............#...........................................................................................................
.....................#........................................................#.....................................................#....... .....................#........................................................#.....................................................#.......
..............................................#.......#................#...............................................#...................# ..............................................#.......#................#...............................................#...................#
.........................................................................................#...............#...................#.............. .........................................................................................#...............#...................#..............
.#...........................#.......#...................................................................................................... .#...........................#.......#......................................................................................................
.............................................................................................................#........................#..... .............................................................................................................#........................#.....
.................................#.......................................................................................................... .................................#..........................................................................................................
...........#........................................................................................#.............................#......... ...........#........................................................................................#.............................#.........
................#...............................................#............................#...................#.......................... ................#...............................................#............................#...................#..........................
...#............................................................................#........................................................... ...#............................................................................#...........................................................
....................................................#.......#.......#......#...........................................................#.... ....................................................#.......#.......#......#...........................................................#....
.........................#.................................................................................................................. .........................#..................................................................................................................
....................#...............#.........................................................................................#............. ....................#...............#.........................................................................................#.............
.........................................................#....................#......................#...................................... .........................................................#....................#......................#......................................
....#........................#...............#........................#...............#..................................................... ....#........................#...............#........................#...............#.....................................................
..........#......#....................................................................................................................#..... ..........#......#....................................................................................................................#.....
..............................................................................................#...................#......................... ..............................................................................................#...................#.........................
.......................................................#...................................................#.................#.............. .......................................................#...................................................#.................#..............
..........................#....................#............................................................................................ ..........................#....................#............................................................................................
........................................#......................#.........#...............#.......#......................#.........#.....#... ........................................#......................#.........#...............#.......#......................#.........#.....#...
...............................#....................................#....................................................................... ...............................#....................................#.......................................................................
........#...........#.............................#......................................................................................... ........#...........#.............................#.........................................................................................
...#...........#...................................................................#..................#............#........................ ...#...........#...................................................................#..................#............#........................
...........................#..............................#...................................#............................................. ...........................#..............................#...................................#.............................................
...................................#.............................#..........................................#............................... ...................................#.............................#..........................................#...............................
..............................................#........................#........#..........................................#................ ..............................................#........................#........#..........................................#................
.......................................................................................#.............................#..............#....... .......................................................................................#.............................#..............#.......
.........................................#.................................................................................................. .........................................#..................................................................................................
.....#............#......................................#.....#............................#............................................... .....#............#......................................#.....#............................#...............................................
............................#............................................................................................................... ............................#...............................................................................................................
.......................#.........#........................................#..............................#...............................#.. .......................#.........#........................................#..............................#...............................#..
..#...........#.......................................#.........................#........................................................... ..#...........#.......................................#.........................#...........................................................
.......................................#.........................#.......................................................................... .......................................#.........................#..........................................................................
............................................................#............................................................................... ............................................................#...............................................................................
.......#......................#........................................#................................................#..............#.... .......#......................#........................................#................................................#..............#....
..............................................................................................................#............................. ..............................................................................................................#.............................
...............................................#.....................................................#...................................... ...............................................#.....................................................#......................................
......................#..................................................................#......#.................................#.......#. ......................#..................................................................#......#.................................#.......#.
..#.......#................#......#..................................#.......#.....................................#........................ ..#.......#................#......#..................................#.......#.....................................#........................
................#...............................................#..................#....................#..................#................ ................#...............................................#..................#....................#..................#................

View File

@ -1,8 +1,8 @@
import { readFileSync } from "fs"; import { readFileSync } from "fs";
const t0 = performance.now(); const t0 = performance.now();
const input = readFileSync("input.txt").toString(); const input = readFileSync("input.txt").toString();
console.log(input); console.log(input);
const t1 = performance.now(); const t1 = performance.now();
console.log(`Runtime: ${t1 - t0}ms`); console.log(`Runtime: ${t1 - t0}ms`);

View File

@ -1,8 +1,8 @@
import { readFileSync } from "fs"; import { readFileSync } from "fs";
const t0 = performance.now(); const t0 = performance.now();
const input = readFileSync("input.txt").toString(); const input = readFileSync("input.txt").toString();
console.log(input); console.log(input);
const t1 = performance.now(); const t1 = performance.now();
console.log(`Runtime: ${t1 - t0}ms`); console.log(`Runtime: ${t1 - t0}ms`);

View File

@ -1,8 +1,8 @@
import { readFileSync } from "fs"; import { readFileSync } from "fs";
const t0 = performance.now(); const t0 = performance.now();
const input = readFileSync("input.txt").toString(); const input = readFileSync("input.txt").toString();
console.log(input); console.log(input);
const t1 = performance.now(); const t1 = performance.now();
console.log(`Runtime: ${t1 - t0}ms`); console.log(`Runtime: ${t1 - t0}ms`);

View File

@ -1,8 +1,12 @@
import { readFileSync } from "fs"; import { readFileSync } from "fs";
const t0 = performance.now(); const t0 = performance.now();
const input = readFileSync("input.txt").toString(); const input = readFileSync("input.txt").toString().split("\n")[0].split(",");
console.log(input); const hashes = input.map((e) =>
e.split("").reduce((a, i) => ((a + i.charCodeAt(0)) * 17) % 256, 0)
const t1 = performance.now(); );
console.log(`Runtime: ${t1 - t0}ms`); const sum = hashes.reduce((a, i) => a + i);
console.log(sum);
const t1 = performance.now();
console.log(`Runtime: ${t1 - t0}ms`);

12
Day15/Part2.js Normal file
View File

@ -0,0 +1,12 @@
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`);

8
Day16/Part1.js Normal file
View File

@ -0,0 +1,8 @@
import { readFileSync } from "fs";
const t0 = performance.now();
const input = readFileSync("input.txt").toString();
console.log(input);
const t1 = performance.now();
console.log(`Runtime: ${t1 - t0}ms`);

110
Day16/input.txt Normal file
View File

@ -0,0 +1,110 @@
\.\............/........|............/.-....................|............|.......-..............//....../../..
......\.-/..|...............-...-\......../.............-.../.............../........-................../../..
.........\..\......................................................../\.......\.............................-.
....|.........-..................|..../....-......................................|.../...............|.../...
.....|...|..-....|................/............./......./............../|.......|.....|.................../...
.........-............../.|.-...\..........................|..................//............-\......|.........
.........|...................||.........-.|/.......---...-...........\........\.-...\..../......|.............
.......|-................................................................./........../..../...................
......-......|......././...............................\.....\.........|...........|..\-............|\........
|...\.............................-...\\-.................|................................-.........|........
...\....|.|........................-.........................\..|............................-....|...........
\.........|..|./....................../..........-......|...-....................\....-../...\.-.....|/.......
......\./................|...................-....../..................................|.......-....-.........
......-.........................................|....\..................../-./-.......|........./.............
................|...|...\....\....-....//........./...../.....-..............|\.|..\.........\......./\....\.\
.\...|.....|......./....-...........|.............-..\...-..-....................|.../.....-...........--.....
......................................-................../..............\.\\........../.../................\..
.-..........|..|......................|....|.-|.....................-..../............|......./..../..\/.-.\..
..\..\.............../-......-................-......................................\....../......|..........
.........\.....\.......................................-../........./-....-.................\....../..../.....
......-..\..-.............|...................|....../.......\../........../.....-............................
.............|../.\...\....|...............|.........../..|-....../........../..../|.|.\........|........\..|.
..\............|...../...................\......................./...-.......-..........................-.....
....|......................|......../.|.\.../......|...|..-.....................|................../..\.......
.....................................................-................/\..-....|..........................-.\.
................../...\..........\...........\............................................./.../.........|.|..
.....-......................................./....-........|.-........................|.........\.....\.......
...............\/\..........|.|................................|.\......\......\............|...-.............
..................................\.......-.........|-........../...........\\..\.|../......|........\..|.....
..............-...........\.....\\./......................./...-...........-..........................././....
...-..............-..........................\..........|...........-/........../.../...|.....................
...\..............-......./-...........|............./.......-./........-..-....|......./\.-.......\./........
.........|......././..\.-......./............-....-..................|....-......../........-.........\.......
....|.........................../....................-..................-...\|............................|...
.-........-...........|..............................|.........................................\......-......-
............./......../..-....\...............................././.......|................................|...
.|\../......-./........./...............-./..............\../..............|....|........./...................
..................................................|............................-..............................
.............-...................\.......|........|.............../......-....|......../.../.-...\|...........
.................../..............-|........................|.............\..\.........................././...
...../.........../..-.......|........../.......|........................./......|......./..........|..........
../...-........../...........................-.|..\../..................\.....-...........|...................
.........\.......-.......-.\.|......|.......||......|.\....-...-.................-..........-..\..............
................................\./.......\/............-................./.....\......../....................
/...........-......|..|....../.....\.........|.....................................\...................|....-.
...........\.............../.......\......................................................................\..-
....../...................-..................|-\......................-..................\....................
/............./...........|.....|............/.................................-....................-......\|.
...............\..|..............|............\../.../..........................\\................|......./...
....--/............|......|......-........-...../........./.........../-..\..|........-.......................
|.-....-.........................|../................\................../......\..../.\..|...../.../|.........
....................................../.........\........-....................../.-..-.\.....././.../.....\..\
......\...../............./................-...........\.................../.....-../......-..................
....../............../...........|......|..................................|...................|..............
......-../.../.|.........././..........\.......\........./......|..............\.................-.........../
...../...|........//...../.................\................../.\.............-............/.........../......
..............-.....|................\................/.........|.....\.......\....................\.....\....
..........|..........-.../..................\.-.......................................\..-.........|..........
....|..................-.....|..................|...........-......./.....-......../...|........\....\-.|.....
.......................-......./......................./.-.-.........|.....|.................|................
...|................/......-.....|....-..-.........-|....|..................../.../....-......\.......-......\
............-.............................-...................../..............|.|.......-....................
-....-..............|................./......../.\............./../............../..-...-...........|.........
.|............|..........-................./................|.....................|./....\......./.....\......
..........|\.|...................-.............\......|..-..\.......\..........\........|......-.../........\.
\.......\....................\..............|................................|..............-.../.............
......../-....................|...............-........................\................\..............-......
...|..-.............//.-.............../........-........../..|.............\|../....................-........
..../.\.-.-|.....\.-|..../.....\..|.........../........................-.....................-..........|.....
...../-..........\.........-....................\.............................\............|-..\..........|...
...-...../....................../-......\...|.....-........................../.|.........|.......\..\.....\../
...................\...../......................./...-.....\.-.........-...../.|...................|......./..
../.....|..|..\.........|.../.................../..-............\../........\.....\.....................\.....
.........................../...\.|........\...||..........\......\.-....|.........\-..\.......................
../.........|............................/../-||..............|-........\............\....\.\................|
../....|....................|.....|-.......|.................../...\.-.\.............-.................-......
....|..............................................................-|.........................................
..................\-.\/.........|../|....../|..\...-...\.........|/............./...\...\.....................
.\.........-../....|-......................./................/\..\........................................./..
./......................-...............|...............|................-.......................\............
................\..........././............................-....\/..........-.../../....|.........-....|...../
.-..-..|\..\/........\./....|.......................\.........../.....|......./-.-..../..../..................
\.....|........................../.|...../.-...............|.../\...|.........|.\|....../.-......|............
.........-|............./..../.\.|//.......-....-...........\.........-..-.........\....\..........|..........
....................|.......-../.....\-..........\................-..................\.-........|.............
.....|.\-........................./........................................../.......-.\....-......../........
...................|..............\..|/................................|/..../........../..|.................|
.......\...|./......../..........-............-....|...........-/.\...-......./....\......./........\....../..
...\............\..........\../................./....-......|..........................................\......
............|......|......../.............\...|.....................\.\\......................................
-.-.-......\.......|..........-.|.....|\....\/..............-/..........|............|......./.........-......
......................../...|................./......\............../..............-/.......\.....\\..........
...|.|.-..-./..................../................................-....\|........./...-..|........\......-....
....\....-../.........|....|........-./..\../...|...../-.|.|....\................................./...|......-
..............\../..............|.|................\......./.............../.\......|.....|..\...../....../...
............|....\......|........|.......\.................................................../.-..............
.|............|...\....................../............................................\.......|.-.-...........
.....-.\|......\.............|............|....-.........\....|.............................../....\....-.|...
............|./.........................\...|..............................\...|..|..............|...-........
.-.....|..................|....-.............-..\..-...............-....-..................-..................
..\......-.-./..................................-............\........./........-.-.............-............-
..../.\--...............//..................................||................\.................|......|......
..|./...\......................|.........../........\.....-....-.................................../-....\....
.........-........\..............................|.......|......../...........|....../......|..\.|..../.......
....../....-....|\............|.....|..\../||....................................\.....................-......
.....\.....--...././......................-........\\............-...............\....-....|................./
........./........../...-................/...........-............................................-........./.
.........-..-...|/..\.........................\............\..-........-.........-...............\......|./.-.
|......................-.....-..-.........../-..................|.....|.........\./........./...-/............
..............-...........|-....-.../.............-........./...../.................../.......--.|....-..../..

View File

@ -1,29 +1,29 @@
# Advent of Code 2023 # Advent of Code 2023
## About ## About
This repository stores my solutions to the daily challenges of [Advent of Code Calendar 2023](https://adventofcode.com/2023/). This repository stores my solutions to the daily challenges of [Advent of Code Calendar 2023](https://adventofcode.com/2023/).
## Execution ## Execution
Any of the scripts can be executed directly using [NodeJS](https://nodejs.org/en/download/). Any of the scripts can be executed directly using [NodeJS](https://nodejs.org/en/download/).
**Example:** **Example:**
```bash ```bash
cd Day01/ cd Day01/
node Part1.js node Part1.js
``` ```
## File explanation ## File explanation
A single challenge consists of 3 files: A single challenge consists of 3 files:
- `input.txt`: My input data, as provided by AoC. - `input.txt`: My input data, as provided by AoC.
- `Part1.js`: My solution to part 1 of the challenge. - `Part1.js`: My solution to part 1 of the challenge.
- `Part2.js`: My solution to part 2 of the challenge. - `Part2.js`: My solution to part 2 of the challenge.
Other special files: Other special files:
- [`template.js`](template.js): A template file to use when initializing a new challenge. - [`template.js`](template.js): A template file to use when initializing a new challenge.
- `sample.js`: Example or test code; Ignored by git (see [.gitignore](.gitignore)). - `sample.js`: Example or test code; Ignored by git (see [.gitignore](.gitignore)).

View File

@ -1,8 +1,8 @@
{ {
"name": "aoc23", "name": "aoc23",
"version": "1.0.0", "version": "1.0.0",
"description": "Advent of Code", "description": "Advent of Code",
"author": "Baipyrus", "author": "Baipyrus",
"license": "ISC", "license": "ISC",
"type": "module" "type": "module"
} }

View File

@ -1,8 +1,8 @@
import { readFileSync } from "fs"; import { readFileSync } from "fs";
const t0 = performance.now(); const t0 = performance.now();
const input = readFileSync("input.txt").toString(); const input = readFileSync("input.txt").toString();
console.log(input); console.log(input);
const t1 = performance.now(); const t1 = performance.now();
console.log(`Runtime: ${t1 - t0}ms`); console.log(`Runtime: ${t1 - t0}ms`);