1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import { LoadInput } from "../common.ts";
- import { BuildSchematicsMap, ParseSchematics, ValidateEngineParts } from "./3_common.ts";
- const tests = [
- "467..114..",
- "...*......",
- "..35..633.",
- "......#...",
- "617*......",
- ".....+.58.",
- "..592.....",
- "......755.",
- "...$.*....",
- ".664.598..",
- ];
- /**
- * Test case from /u/i_have_no_biscuits
- * @see https://www.reddit.com/r/adventofcode/comments/189q9wv/2023_day_3_another_sample_grid_to_use/
- */
- const tests_reddit = [
- "12.......*..",
- "+.........34",
- ".......-12..",
- "..78........",
- "..*....60...",
- "78..........",
- ".......23...",
- "....90*12...",
- "............",
- "2.2......12.",
- ".*.........*",
- "1.1.......56",
- ];
- const input = await LoadInput(3);
- // Build the find
- const schematics = BuildSchematicsMap(input);
- // Find all possible parts
- let engineParts = ParseSchematics(schematics);
- // Validate those parts
- engineParts = ValidateEngineParts(engineParts, schematics);
- // Get our output
- const sumOfPartNumbers = engineParts.reduce((accumulator, part) => accumulator += part.PartNumber, 0);
- console.log(`The sum of part numbers is: ${sumOfPartNumbers}`);
|