Day Eight: Part Two
This commit is contained in:
parent
c86bcbffb6
commit
f81359618d
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user