From f81359618d200cc2b703c3ceefbde345fbe10557 Mon Sep 17 00:00:00 2001 From: Lewis Dale Date: Fri, 8 Dec 2023 10:04:45 +0000 Subject: [PATCH] Day Eight: Part Two --- src/day_eight.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/day_eight.ts b/src/day_eight.ts index d05bc6e..6411094 100644 --- a/src/day_eight.ts +++ b/src/day_eight.ts @@ -1,7 +1,6 @@ -import {anyCharOf, int, newline, uniDecimal, uniLetter, whitespace} from "parjs"; +import {anyCharOf, newline, uniDecimal, uniLetter, whitespace} from "parjs"; import {between, exactly, manySepBy, manyTill, or, stringify, then} from "parjs/combinators"; import fs from "fs"; -import { Set } from 'immutable'; const patternParser = anyCharOf("LR").pipe(manyTill(newline().pipe(exactly(2)))); @@ -90,14 +89,10 @@ export class DesertMap { return step; } - private isComplete(keys: string[]) { - return keys.every(key => key.endsWith('Z')); - } - public ghostStepsToZ(): number { let keys = Object.keys(this.map).filter(key => key.endsWith('A')); - return keys.map(key => this.stepsToZ(key)).reduce(lcm, 1); + return keys.map(key => this.stepsToZ(key)).reduce(lcm); } }