Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TimHi committed Jan 1, 2024
1 parent 7ff038f commit 7fe4066
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 60 deletions.
10 changes: 0 additions & 10 deletions Ruby/2023/.prettierrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Ruby/2023/d2/day02.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def valid?(line)
get_colors_num(split, 'green').sum <= 13 &&
get_colors_num(split, 'blue').sum <= 14
end
.all? { |el| el === true }
.all? { |el| el === true }
end

def solve
Expand Down
37 changes: 0 additions & 37 deletions Ruby/2023/package-lock.json

This file was deleted.

6 changes: 0 additions & 6 deletions Ruby/2023/package.json

This file was deleted.

17 changes: 16 additions & 1 deletion Typescript/2023/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Typescript/2023/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"hamming": "^0.0.2",
"lodash": "^4.17.21",
"nunjucks": "^3.2.4",
"ts-2d-geometry": "^6.3.2"
"ts-2d-geometry": "^6.3.2",
"vector": "^0.0.4",
"vector-math": "^1.1.1"
}
}
22 changes: 21 additions & 1 deletion Typescript/2023/src/days/day24/day24.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import * as fs from "fs";
import { getAllNumbersInString } from "../../util/regex";
import { Vector } from "vector-math";

interface HailStone {
px: number;
py: number;
pz: number;
vx: number;
vy: number;
vz: number;
vector: Vector;
}

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");
const hailStones: HailStone[] = fs
.readFileSync(process.cwd() + fileName, "utf8")
.split("\n")
.map((l) => {
const data = l.split("@");
const pos = getAllNumbersInString(data[0]);
const vel = getAllNumbersInString(data[1]);
return { px: pos[0], py: pos[1], pz: pos[2], vx: vel[0], vy: vel[1], vz: vel[2], vector: new Vector(vel[0], vel[1], vel[2]) };
});

console.log("TBD");
return 0;
Expand Down
5 changes: 5 additions & 0 deletions Typescript/2023/src/days/day24/sample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
19, 13, 30 @ -2, 1, -2
18, 19, 22 @ -1, -1, -2
20, 25, 34 @ -2, -2, -4
12, 31, 28 @ -1, -2, -1
20, 19, 15 @ 1, -5, -3
4 changes: 2 additions & 2 deletions Typescript/2023/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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;
const day: number = 24;

if (day >= 1 && day <= 24) {
if (day >= 1 && day <= 25) {
const solvePartOne = solvers[day].SolvePartOne;
const solvePartTwo = solvers[day].SolvePartTwo;

Expand Down
2 changes: 1 addition & 1 deletion Typescript/2023/src/util/regex.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function getAllNumbersInString(input: string): number[] {
const numReg = new RegExp("[0-9]+", "g");
const numReg = new RegExp("-?[0-9]+", "g");
const matches = input.match(numReg)?.map((n) => Number(n)) ?? [];
return matches;
}

0 comments on commit 7fe4066

Please sign in to comment.