From c896fe1d4deb196482ddbd60fd54a38e165df292 Mon Sep 17 00:00:00 2001 From: Lewis Dale Date: Wed, 6 Dec 2023 08:28:52 +0000 Subject: [PATCH] Tidy up the parser --- src/day_six.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/day_six.ts b/src/day_six.ts index 482f96e..ead7a0a 100644 --- a/src/day_six.ts +++ b/src/day_six.ts @@ -8,12 +8,12 @@ export type Race = [number, number]; const timeName = string('Time:').pipe(then(spaces1())); const distanceName = string('Distance:').pipe(then(spaces1())); -const timeParser = anyCharOf("0123456789").pipe(manySepBy(whitespace().pipe(exactly(2))), stringify(), between(timeName, whitespace())); -const distanceParser = anyCharOf("0123456789").pipe(manySepBy(whitespace().pipe(exactly(2))), stringify(), between(distanceName, whitespace())); +const numbersParser = anyCharOf("0123456789").pipe(manySepBy(whitespace().pipe(exactly(2))), stringify()); +const timeParser = numbersParser.pipe(between(timeName, whitespace())); +const distanceParser = numbersParser.pipe(between(distanceName, whitespace())); const parser = timeParser.pipe(then(distanceParser)); - export class BoatRace { private readonly race: Race;