this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Solve D05P01

modamo-gh e9848fc9 86c0451e

+23
+23
day05/part1.ts
··· 1 + import { readFileSync } from "fs"; 2 + 3 + const [rawRanges, rawIDs] = readFileSync("./input.txt", "utf8").split(/\n\n/); 4 + const ranges = rawRanges.split(/\n/).map((range) => { 5 + const [lowerBound, upperBound] = range.split("-").map(Number); 6 + 7 + return { lowerBound, upperBound }; 8 + }); 9 + const ids = rawIDs.split(/\n/).map(Number); 10 + 11 + let numberOfFreshIngredients = 0; 12 + 13 + for (const id of ids) { 14 + for (const { lowerBound, upperBound } of ranges) { 15 + if (id >= lowerBound && id <= upperBound) { 16 + numberOfFreshIngredients++; 17 + 18 + break; 19 + } 20 + } 21 + } 22 + 23 + console.log(numberOfFreshIngredients);