From 005edfb27966ac834ac4d298af1fa07d8e5554e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kleszczy=C5=84ski?= Date: Sun, 1 Dec 2024 22:10:19 +0100 Subject: [PATCH] reformat --- 2023/11/solution.ts | 6 ++---- 2023/11/space.ts | 25 ++++++++++--------------- 2023/tsconfig.json | 1 - 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/2023/11/solution.ts b/2023/11/solution.ts index 76826b7..9bd583e 100644 --- a/2023/11/solution.ts +++ b/2023/11/solution.ts @@ -2,12 +2,10 @@ import { resolve } from 'node:path' import { readFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { solutionExample, solutionPart1 } from '../util/index.ts' -import { Space } from './space.ts'; +import { Space } from './space.ts' const __dirname = fileURLToPath(new URL('.', import.meta.url)) - - const part1 = (file: string) => { const data = readFileSync(resolve(__dirname, file), 'utf-8').trim() const space = Space.fromString(data, 2) @@ -18,7 +16,7 @@ const part1 = (file: string) => { const galaxiesAfterExpansion = galaxies.map(galaxy => { return { x: expandedX.get(galaxy.x), - y: expandedY.get(galaxy.y) + y: expandedY.get(galaxy.y), } }) diff --git a/2023/11/space.ts b/2023/11/space.ts index daf941a..d0636f8 100644 --- a/2023/11/space.ts +++ b/2023/11/space.ts @@ -1,6 +1,6 @@ const enum SpaceObject { Nothing = '.', - Galaxy = '#' + Galaxy = '#', } interface Point { @@ -11,17 +11,14 @@ interface Point { class Space { protected constructor( private image: Array>, - private expansionFactor: number - ) { - } + private expansionFactor: number, + ) {} expand(points: Array): Map { points = [...new Set(points)] points.sort() - return new Map( - points.map((point, index) => [point, this.expansionFactor * (point - index) + index]) - ) + return new Map(points.map((point, index) => [point, this.expansionFactor * (point - index) + index])) } galaxies(): ReadonlyArray { @@ -30,7 +27,7 @@ class Space { .map((object, x) => { return { object, - x + x, } }) .filter(data => { @@ -39,13 +36,13 @@ class Space { .map(data => { return { x: data.x, - y + y, } }) }) } - routesBetween(galaxies: ReadonlyArray): ReadonlyArray<{ from: Point, to: Point }> { + routesBetween(galaxies: ReadonlyArray): ReadonlyArray<{ from: Point; to: Point }> { return galaxies.reduce((routes, galaxy, index) => { const nextGalaxies = galaxies.slice(index + 1) @@ -53,9 +50,9 @@ class Space { nextGalaxies.map(nextGalaxy => { return { from: { ...galaxy }, - to: { ...nextGalaxy } + to: { ...nextGalaxy }, } - }) + }), ) }, []) } @@ -67,9 +64,7 @@ class Space { } static fromString(data: string, expansionFactor: number): Space { - const image: Array> = data - .split('\n') - .map(line => line.split('')) as Array> + const image: Array> = data.split('\n').map(line => line.split('')) as Array> return new Space(image, expansionFactor) } diff --git a/2023/tsconfig.json b/2023/tsconfig.json index 640ea06..3c43903 100644 --- a/2023/tsconfig.json +++ b/2023/tsconfig.json @@ -1,4 +1,3 @@ { "extends": "../tsconfig.json" } -