From 7adb30320d906dfed3f3126e7d385aeab34c56a6 Mon Sep 17 00:00:00 2001 From: TimHi Date: Sat, 23 Dec 2023 13:01:46 +0100 Subject: [PATCH] generate missing days --- .../2023/src/days/__test__/day22.test.ts | 15 +++ .../2023/src/days/__test__/day23.test.ts | 15 +++ .../2023/src/days/__test__/day24.test.ts | 15 +++ Typescript/2023/src/days/day22/day22.ts | 16 +++ Typescript/2023/src/days/day22/sample.txt | 0 Typescript/2023/src/days/day23/day23.ts | 16 +++ Typescript/2023/src/days/day23/sample.txt | 0 Typescript/2023/src/days/day24/day24.ts | 16 +++ Typescript/2023/src/days/day24/sample.txt | 0 Typescript/2023/src/main.ts | 101 +++--------------- 10 files changed, 108 insertions(+), 86 deletions(-) create mode 100644 Typescript/2023/src/days/__test__/day22.test.ts create mode 100644 Typescript/2023/src/days/__test__/day23.test.ts create mode 100644 Typescript/2023/src/days/__test__/day24.test.ts create mode 100644 Typescript/2023/src/days/day22/day22.ts create mode 100644 Typescript/2023/src/days/day22/sample.txt create mode 100644 Typescript/2023/src/days/day23/day23.ts create mode 100644 Typescript/2023/src/days/day23/sample.txt create mode 100644 Typescript/2023/src/days/day24/day24.ts create mode 100644 Typescript/2023/src/days/day24/sample.txt diff --git a/Typescript/2023/src/days/__test__/day22.test.ts b/Typescript/2023/src/days/__test__/day22.test.ts new file mode 100644 index 0000000..d3d942f --- /dev/null +++ b/Typescript/2023/src/days/__test__/day22.test.ts @@ -0,0 +1,15 @@ + +import { SolvePartOne, SolvePartTwo } from "../day22/day22"; +import { describe, expect, test } from "vitest"; + +describe("Day 22 Part 01", () => { + test("Expected result", () => { + expect(SolvePartOne()).toBe(-1); + }); +}); + +describe("Day 22 Part 02", () => { + test("Expected result", () => { + expect(SolvePartTwo()).toBe(-1); + }); +}); diff --git a/Typescript/2023/src/days/__test__/day23.test.ts b/Typescript/2023/src/days/__test__/day23.test.ts new file mode 100644 index 0000000..d471b90 --- /dev/null +++ b/Typescript/2023/src/days/__test__/day23.test.ts @@ -0,0 +1,15 @@ + +import { SolvePartOne, SolvePartTwo } from "../day23/day23"; +import { describe, expect, test } from "vitest"; + +describe("Day 23 Part 01", () => { + test("Expected result", () => { + expect(SolvePartOne()).toBe(-1); + }); +}); + +describe("Day 23 Part 02", () => { + test("Expected result", () => { + expect(SolvePartTwo()).toBe(-1); + }); +}); diff --git a/Typescript/2023/src/days/__test__/day24.test.ts b/Typescript/2023/src/days/__test__/day24.test.ts new file mode 100644 index 0000000..9061780 --- /dev/null +++ b/Typescript/2023/src/days/__test__/day24.test.ts @@ -0,0 +1,15 @@ + +import { SolvePartOne, SolvePartTwo } from "../day24/day24"; +import { describe, expect, test } from "vitest"; + +describe("Day 24 Part 01", () => { + test("Expected result", () => { + expect(SolvePartOne()).toBe(-1); + }); +}); + +describe("Day 24 Part 02", () => { + test("Expected result", () => { + expect(SolvePartTwo()).toBe(-1); + }); +}); diff --git a/Typescript/2023/src/days/day22/day22.ts b/Typescript/2023/src/days/day22/day22.ts new file mode 100644 index 0000000..298fd8b --- /dev/null +++ b/Typescript/2023/src/days/day22/day22.ts @@ -0,0 +1,16 @@ +import * as fs from "fs"; + +const isSample = true; + +export function SolvePartOne(): number { + const fileName = isSample ? "/src/days/day22/sample.txt" : "/src/days/day22/full.txt"; + const lines = fs.readFileSync(process.cwd() + fileName, "utf8").split("\n"); + + console.log("TBD"); + return 0; +} + +export function SolvePartTwo(): number { + console.log("TBD"); + return 0; +} diff --git a/Typescript/2023/src/days/day22/sample.txt b/Typescript/2023/src/days/day22/sample.txt new file mode 100644 index 0000000..e69de29 diff --git a/Typescript/2023/src/days/day23/day23.ts b/Typescript/2023/src/days/day23/day23.ts new file mode 100644 index 0000000..1ba3ab7 --- /dev/null +++ b/Typescript/2023/src/days/day23/day23.ts @@ -0,0 +1,16 @@ +import * as fs from "fs"; + +const isSample = true; + +export function SolvePartOne(): number { + const fileName = isSample ? "/src/days/day23/sample.txt" : "/src/days/day23/full.txt"; + const lines = fs.readFileSync(process.cwd() + fileName, "utf8").split("\n"); + + console.log("TBD2"); + return 0; +} + +export function SolvePartTwo(): number { + console.log("TBD2"); + return 0; +} diff --git a/Typescript/2023/src/days/day23/sample.txt b/Typescript/2023/src/days/day23/sample.txt new file mode 100644 index 0000000..e69de29 diff --git a/Typescript/2023/src/days/day24/day24.ts b/Typescript/2023/src/days/day24/day24.ts new file mode 100644 index 0000000..114e8a6 --- /dev/null +++ b/Typescript/2023/src/days/day24/day24.ts @@ -0,0 +1,16 @@ +import * as fs from "fs"; + +const isSample = true; + +export function SolvePartOne(): number { + const fileName = isSample ? "/src/days/day24/sample.txt" : "/src/days/day24/full.txt"; + const lines = fs.readFileSync(process.cwd() + fileName, "utf8").split("\n"); + + console.log("TBD"); + return 0; +} + +export function SolvePartTwo(): number { + console.log("TBD"); + return 0; +} diff --git a/Typescript/2023/src/days/day24/sample.txt b/Typescript/2023/src/days/day24/sample.txt new file mode 100644 index 0000000..e69de29 diff --git a/Typescript/2023/src/main.ts b/Typescript/2023/src/main.ts index aa1bfed..23aec1c 100644 --- a/Typescript/2023/src/main.ts +++ b/Typescript/2023/src/main.ts @@ -1,88 +1,17 @@ -import { SolvePartOne, SolvePartTwo } from "./days/day01/day01"; -import { SolvePartOne as SolvePartOneD2, SolvePartTwo as SolvePartTwoD2 } from "./days/day02/day02"; -import { SolvePartOne as SolvePartOneD3, SolvePartTwo as SolvePartTwoD3 } from "./days/day03/day03"; -import { SolvePartOne as SolvePartOneD4, SolvePartTwo as SolvePartTwoD4 } from "./days/day04/day04"; -import { SolvePartOne as SolvePartOneD5, SolvePartTwo as SolvePartTwoD5 } from "./days/day05/day05"; -import { SolvePartOne as SolvePartOneD6, SolvePartTwo as SolvePartTwoD6 } from "./days/day06/day06"; -import { SolvePartOne as SolvePartOneD7, SolvePartTwo as SolvePartTwoD7 } from "./days/day07/day07"; -import { SolvePartOne as SolvePartOneD8, SolvePartTwo as SolvePartTwoD8 } from "./days/day08/day08"; -import { SolvePartOne as SolvePartOneD9, SolvePartTwo as SolvePartTwoD9 } from "./days/day09/day09"; -import { SolvePartOne as SolvePartOneD10, SolvePartTwo as SolvePartTwoD10 } from "./days/day10/day10"; -import { SolvePartOne as SolvePartOneD11, SolvePartTwo as SolvePartTwoD11 } from "./days/day11/day11"; -import { SolvePartOne as SolvePartOneD12, SolvePartTwo as SolvePartTwoD12 } from "./days/day12/day12"; -import { SolvePartOne as SolvePartOneD13, SolvePartTwo as SolvePartTwoD13 } from "./days/day13/day13"; -import { SolvePartOne as SolvePartOneD14, SolvePartTwo as SolvePartTwoD14 } from "./days/day14/day14"; -import { SolvePartOne as SolvePartOneD15, SolvePartTwo as SolvePartTwoD15 } from "./days/day15/day15"; -import { SolvePartOne as SolvePartOneD16, SolvePartTwo as SolvePartTwoD16 } from "./days/day16/day16"; -import { SolvePartOne as SolvePartOneD17, SolvePartTwo as SolvePartTwoD17 } from "./days/day17/day17"; -import { SolvePartOne as SolvePartOneD18, SolvePartTwo as SolvePartTwoD18 } from "./days/day18/day18"; -import { SolvePartOne as SolvePartOneD19, SolvePartTwo as SolvePartTwoD19 } from "./days/day19/day19"; -import { SolvePartOne as SolvePartOneD20, SolvePartTwo as SolvePartTwoD20 } from "./days/day20/day20"; -import { SolvePartOne as SolvePartOneD21, SolvePartTwo as SolvePartTwoD21 } from "./days/day21/day21"; -//Please don't look at this file I dont care its ugly -const day: number = 20; +// Import all solver functions dynamically +const solvers = []; +for (let i = 1; i <= 24; i++) { + solvers[i] = require(`./days/day${i.toString().padStart(2, "0")}/day${i.toString().padStart(2, "0")}`); +} + +const day: number = 23; + +if (day >= 1 && day <= 24) { + const solvePartOne = solvers[day].SolvePartOne; + const solvePartTwo = solvers[day].SolvePartTwo; -if (day === 1) { - console.log("Day 01 Part 01: " + SolvePartOne()); - console.log("Day 01 Part 02: " + SolvePartTwo()); -} else if (day === 2) { - console.log("Day 02 Part 01: " + SolvePartOneD2()); - console.log("Day 02 Part 02: " + SolvePartTwoD2()); -} else if (day === 3) { - console.log("Day 03 Part 01: " + SolvePartOneD3()); - console.log("Day 03 Part 02: " + SolvePartTwoD3()); -} else if (day === 4) { - console.log("Day 04 Part 01: " + SolvePartOneD4()); - console.log("Day 04 Part 02: " + SolvePartTwoD4()); -} else if (day === 5) { - console.log("Day 05 Part 01: " + SolvePartOneD5()); - console.log("Day 05 Part 02: " + SolvePartTwoD5()); -} else if (day === 6) { - console.log("Day 06 Part 01: " + SolvePartOneD6()); - console.log("Day 06 Part 02: " + SolvePartTwoD6()); -} else if (day === 7) { - console.log("Day 07 Part 01: " + SolvePartOneD7()); - console.log("Day 07 Part 02: " + SolvePartTwoD7()); -} else if (day === 8) { - console.log("Day 08 Part 01: " + SolvePartOneD8()); - console.log("Day 08 Part 02: " + SolvePartTwoD8()); -} else if (day === 9) { - console.log("Day 09 Part 01: " + SolvePartOneD9()); - console.log("Day 09 Part 02: " + SolvePartTwoD9()); -} else if (day === 10) { - console.log("Day 10 Part 01: " + SolvePartOneD10()); - console.log("Day 10 Part 02: " + SolvePartTwoD10()); -} else if (day === 11) { - console.log("Day 11 Part 01: " + SolvePartOneD11()); - console.log("Day 11 Part 02: " + SolvePartTwoD11()); -} else if (day === 12) { - console.log("Day 12 Part 01: " + SolvePartOneD12()); - console.log("Day 12 Part 02: " + SolvePartTwoD12()); -} else if (day === 13) { - console.log("Day 13 Part 01: " + SolvePartOneD13()); - console.log("Day 13 Part 02: " + SolvePartTwoD13()); -} else if (day === 14) { - console.log("Day 14 Part 01: " + SolvePartOneD14()); - console.log("Day 14 Part 02: " + SolvePartTwoD14()); -} else if (day === 15) { - console.log("Day 15 Part 01: " + SolvePartOneD15()); - console.log("Day 15 Part 02: " + SolvePartTwoD15()); -} else if (day === 16) { - console.log("Day 16 Part 01: " + SolvePartOneD16()); - console.log("Day 16 Part 02: " + SolvePartTwoD16()); -} else if (day === 17) { - console.log("Day 17 Part 01: " + SolvePartOneD17()); - console.log("Day 17 Part 02: " + SolvePartTwoD17()); -} else if (day === 18) { - console.log("Day 18 Part 01: " + SolvePartOneD18()); - console.log("Day 18 Part 02: " + SolvePartTwoD18()); -} else if (day === 19) { - console.log("Day 19 Part 01: " + SolvePartOneD19()); - console.log("Day 19 Part 02: " + SolvePartTwoD19()); -} else if (day === 20) { - console.log("Day 20 Part 01: " + SolvePartOneD20()); - console.log("Day 20 Part 02: " + SolvePartTwoD20()); -} else if (day === 21) { - console.log("Day 21 Part 01: " + SolvePartOneD21()); - console.log("Day 21 Part 02: " + SolvePartTwoD21()); + console.log(`Day ${day} Part 01: ${solvePartOne()}`); + console.log(`Day ${day} Part 02: ${solvePartTwo()}`); +} else { + console.log("Invalid day input"); }