12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import * as fs from "fs";
- import * as readline from "readline";
- import * as util from "util";
- export async function LoadInput(dayNumber: number): Promise<string[]> {
- const contents = [];
- const stream = fs.createReadStream(`./inputs/${dayNumber}.txt`, "utf8");
- const rl = readline.createInterface({
- input: stream,
- crlfDelay: Infinity,
- });
- for await (const line of rl) {
- contents.push(line);
- }
- return contents;
- }
- export function Inspect(value: any): void {
- console.log(util.inspect(value, { breakLength: Infinity, colors: true, depth: 256 }));
- }
- export function DeepClone(value: any): any {
- return JSON.parse(JSON.stringify(value));
- }
- export function ExtractNumbers(str: string): number[] {
- return str.split(/\D/).filter((n) => n.length).map((n) => Number(n));
- }
|