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); } }