├── .assets └── test-output-screenshot.png ├── .gitignore ├── .prettierrc ├── .vscode ├── launch.json ├── settings.json └── snippets.code-snippets ├── .zsh_config ├── LICENSE ├── bun.lockb ├── compareTemplate.dat ├── config.ts ├── getToken.ts ├── index.ts ├── init.ts ├── login.ts ├── package-lock.json ├── package.json ├── readme.md ├── run.ts ├── solutionTemplate.ts.dat ├── submit.ts ├── tsconfig.json ├── util ├── @types │ └── global │ │ └── index.d.ts ├── graph.ts ├── grid.ts ├── log.ts ├── test.ts └── util.ts └── years ├── 2015 ├── 10 │ ├── data.txt │ └── index.ts ├── 11 │ ├── data.txt │ └── index.ts ├── 12 │ ├── data.txt │ └── index.ts ├── 13 │ ├── data.txt │ └── index.ts ├── 14 │ ├── data.txt │ └── index.ts ├── 15 │ ├── data.txt │ └── index.ts ├── 16 │ ├── data.txt │ └── index.ts ├── 17 │ ├── data.txt │ └── index.ts ├── 18 │ ├── data.txt │ └── index.ts ├── 19 │ ├── data.txt │ └── index.ts ├── 20 │ ├── data.txt │ └── index.ts ├── 21 │ ├── data.txt │ └── index.ts ├── 22 │ ├── data.txt │ └── index.ts ├── 23 │ ├── data.txt │ └── index.ts ├── 24 │ ├── data.txt │ └── index.ts ├── 25 │ ├── data.txt │ └── index.ts ├── 01 │ ├── data.txt │ └── index.ts ├── 02 │ ├── data.txt │ └── index.ts ├── 03 │ ├── data.txt │ └── index.ts ├── 04 │ ├── data.txt │ └── index.ts ├── 05 │ ├── data.txt │ └── index.ts ├── 06 │ ├── data.txt │ └── index.ts ├── 07 │ ├── data.txt │ └── index.ts ├── 08 │ ├── data.txt │ └── index.ts └── 09 │ ├── data.txt │ └── index.ts ├── 2016 ├── 10 │ ├── data.txt │ └── index.ts ├── 11 │ ├── data.txt │ └── index.ts ├── 12 │ ├── data.txt │ └── index.ts ├── 13 │ ├── data.txt │ └── index.ts ├── 14 │ ├── data.txt │ └── index.ts ├── 15 │ ├── data.txt │ └── index.ts ├── 16 │ ├── data.txt │ └── index.ts ├── 17 │ ├── data.txt │ └── index.ts ├── 18 │ ├── data.txt │ └── index.ts ├── 19 │ ├── data.txt │ └── index.ts ├── 20 │ ├── data.txt │ └── index.ts ├── 21 │ ├── data.txt │ └── index.ts ├── 22 │ ├── data.txt │ └── index.ts ├── 23 │ ├── data.txt │ └── index.ts ├── 24 │ ├── data.txt │ └── index.ts ├── 25 │ ├── data.txt │ └── index.ts ├── 01 │ ├── data.txt │ └── index.ts ├── 02 │ ├── data.txt │ └── index.ts ├── 03 │ ├── data.txt │ └── index.ts ├── 04 │ ├── data.txt │ └── index.ts ├── 05 │ ├── data.txt │ └── index.ts ├── 06 │ ├── data.txt │ └── index.ts ├── 07 │ ├── data.txt │ └── index.ts ├── 08 │ ├── data.txt │ └── index.ts └── 09 │ ├── data.txt │ └── index.ts ├── 2017 ├── 10 │ ├── data.txt │ └── index.ts ├── 11 │ ├── data.txt │ └── index.ts ├── 12 │ ├── data.txt │ └── index.ts ├── 13 │ ├── data.txt │ └── index.ts ├── 14 │ ├── data.txt │ └── index.ts ├── 15 │ ├── data.txt │ └── index.ts ├── 16 │ ├── data.txt │ └── index.ts ├── 17 │ ├── data.txt │ └── index.ts ├── 18 │ ├── data.txt │ └── index.ts ├── 19 │ ├── data.txt │ └── index.ts ├── 20 │ ├── data.txt │ └── index.ts ├── 21 │ ├── data.txt │ └── index.ts ├── 22 │ ├── data.txt │ └── index.ts ├── 23 │ ├── data.txt │ └── index.ts ├── 24 │ ├── data.txt │ └── index.ts ├── 25 │ ├── data.txt │ └── index.ts ├── 01 │ ├── data.txt │ └── index.ts ├── 02 │ ├── data.txt │ └── index.ts ├── 03 │ ├── data.txt │ └── index.ts ├── 04 │ ├── data.txt │ └── index.ts ├── 05 │ ├── data.txt │ └── index.ts ├── 06 │ ├── data.txt │ └── index.ts ├── 07 │ ├── data.txt │ └── index.ts ├── 08 │ ├── data.txt │ └── index.ts └── 09 │ ├── data.txt │ └── index.ts ├── 2018 ├── 10 │ ├── data.txt │ └── index.ts ├── 11 │ ├── data.txt │ └── index.ts ├── 12 │ ├── data.txt │ └── index.ts ├── 13 │ ├── data.txt │ └── index.ts ├── 14 │ ├── data.txt │ └── index.ts ├── 15 │ ├── data.txt │ └── index.ts ├── 16 │ ├── data.txt │ └── index.ts ├── 17 │ ├── data.txt │ └── index.ts ├── 18 │ ├── data.txt │ └── index.ts ├── 19 │ ├── data.txt │ └── index.ts ├── 20 │ ├── data.txt │ └── index.ts ├── 21 │ ├── data.txt │ └── index.ts ├── 22 │ ├── data.txt │ └── index.ts ├── 23 │ ├── data.txt │ └── index.ts ├── 24 │ ├── data.txt │ └── index.ts ├── 25 │ ├── data.txt │ └── index.ts ├── 01 │ ├── data.txt │ └── index.ts ├── 02 │ ├── data.txt │ └── index.ts ├── 03 │ ├── data.txt │ └── index.ts ├── 04 │ ├── data.txt │ └── index.ts ├── 05 │ ├── data.txt │ └── index.ts ├── 06 │ ├── data.txt │ └── index.ts ├── 07 │ ├── data.txt │ └── index.ts ├── 08 │ ├── data.txt │ └── index.ts └── 09 │ ├── data.txt │ └── index.ts ├── 2019 ├── 10 │ ├── data.txt │ └── index.ts ├── 11 │ ├── data.txt │ └── index.ts ├── 12 │ ├── data.txt │ └── index.ts ├── 13 │ ├── data.txt │ └── index.ts ├── 14 │ ├── data.txt │ └── index.ts ├── 15 │ ├── data.txt │ └── index.ts ├── 16 │ ├── data.txt │ └── index.ts ├── 17 │ ├── data.txt │ └── index.ts ├── 18 │ ├── data.txt │ └── index.ts ├── 19 │ ├── data.txt │ └── index.ts ├── 20 │ ├── data.txt │ └── index.ts ├── 21 │ ├── data.txt │ └── index.ts ├── 22 │ ├── data.txt │ └── index.ts ├── 23 │ ├── data.txt │ └── index.ts ├── 24 │ ├── data.txt │ └── index.ts ├── 25 │ ├── data.txt │ └── index.ts ├── 01 │ ├── data.txt │ └── index.ts ├── 02 │ ├── data.txt │ └── index.ts ├── 03 │ ├── data.txt │ └── index.ts ├── 04 │ ├── data.txt │ └── index.ts ├── 05 │ ├── data.txt │ └── index.ts ├── 06 │ ├── data.txt │ └── index.ts ├── 07 │ ├── data.txt │ └── index.ts ├── 08 │ ├── data.txt │ └── index.ts ├── 09 │ ├── data.txt │ └── index.ts ├── bigintcode.ts └── intcode.ts ├── 2020 ├── 10 │ ├── data.txt │ └── index.ts ├── 11 │ ├── data.txt │ └── index.ts ├── 12 │ ├── data.txt │ └── index.ts ├── 13 │ ├── data.txt │ └── index.ts ├── 14 │ ├── data.txt │ └── index.ts ├── 15 │ ├── data.txt │ └── index.ts ├── 16 │ ├── data.txt │ └── index.ts ├── 17 │ ├── data.txt │ └── index.ts ├── 18 │ ├── data.txt │ ├── index-alternate.ts │ └── index.ts ├── 19 │ ├── data.txt │ └── index.ts ├── 20 │ ├── data.txt │ └── index.ts ├── 21 │ ├── data.txt │ └── index.ts ├── 22 │ ├── data.txt │ └── index.ts ├── 23 │ ├── data.txt │ └── index.ts ├── 24 │ ├── data.txt │ └── index.ts ├── 25 │ ├── data.txt │ └── index.ts ├── 01 │ ├── data.txt │ └── index.ts ├── 02 │ ├── data.txt │ └── index.ts ├── 03 │ ├── data.txt │ └── index.ts ├── 04 │ ├── data.txt │ └── index.ts ├── 05 │ ├── data.txt │ └── index.ts ├── 06 │ ├── data.txt │ └── index.ts ├── 07 │ ├── data.txt │ └── index.ts ├── 08 │ ├── data.txt │ └── index.ts └── 09 │ ├── data.txt │ └── index.ts ├── 2021 ├── 10 │ ├── data.txt │ └── index.ts ├── 11 │ ├── data.txt │ └── index.ts ├── 12 │ ├── data.txt │ └── index.ts ├── 13 │ ├── data.txt │ └── index.ts ├── 14 │ ├── data.txt │ └── index.ts ├── 15 │ ├── data.txt │ └── index.ts ├── 16 │ ├── data.txt │ └── index.ts ├── 17 │ ├── data.txt │ └── index.ts ├── 18 │ ├── data.txt │ └── index.ts ├── 19 │ ├── data.txt │ ├── index.ts │ └── meta.ts ├── 20 │ ├── data.txt │ └── index.ts ├── 21 │ ├── data.txt │ └── index.ts ├── 22 │ ├── data.txt │ └── index.ts ├── 23 │ ├── data.txt │ └── index.ts ├── 24 │ ├── data.txt │ └── index.ts ├── 25 │ ├── data.txt │ └── index.ts ├── 01 │ ├── data.txt │ └── index.ts ├── 02 │ ├── data.txt │ └── index.ts ├── 03 │ ├── data.txt │ └── index.ts ├── 04 │ ├── data.txt │ └── index.ts ├── 05 │ ├── data.txt │ └── index.ts ├── 06 │ ├── data.txt │ └── index.ts ├── 07 │ ├── data.txt │ └── index.ts ├── 08 │ ├── data.txt │ └── index.ts └── 09 │ ├── data.txt │ └── index.ts ├── 2022 ├── 10 │ ├── data.txt │ └── index.ts ├── 11 │ ├── data.txt │ └── index.ts ├── 12 │ ├── data.txt │ └── index.ts ├── 13 │ ├── data.txt │ └── index.ts ├── 14 │ ├── data.txt │ └── index.ts ├── 15 │ ├── data.txt │ └── index.ts ├── 16 │ ├── data.txt │ └── index.ts ├── 17 │ ├── data.txt │ └── index.ts ├── 18 │ ├── data.txt │ └── index.ts ├── 19 │ ├── data.txt │ └── index.ts ├── 20 │ ├── data.txt │ └── index.ts ├── 21 │ ├── data.txt │ └── index.ts ├── 22 │ ├── data.txt │ └── index.ts ├── 23 │ ├── data.txt │ └── index.ts ├── 24 │ ├── data.txt │ └── index.ts ├── 25 │ ├── data.txt │ └── index.ts ├── 01 │ ├── data.txt │ └── index.ts ├── 02 │ ├── data.txt │ └── index.ts ├── 03 │ ├── data.txt │ └── index.ts ├── 04 │ ├── data.txt │ └── index.ts ├── 05 │ ├── data.txt │ └── index.ts ├── 06 │ ├── data.txt │ └── index.ts ├── 07 │ ├── data.txt │ └── index.ts ├── 08 │ ├── data.txt │ └── index.ts └── 09 │ ├── data.txt │ └── index.ts ├── 2023 ├── 10 │ ├── data.txt │ └── index.ts ├── 11 │ ├── data.txt │ └── index.ts ├── 12 │ ├── data.txt │ └── index.ts ├── 13 │ ├── data.txt │ └── index.ts ├── 14 │ ├── data.txt │ └── index.ts ├── 15 │ ├── data.txt │ └── index.ts ├── 16 │ ├── data.txt │ └── index.ts ├── 17 │ ├── data.txt │ └── index.ts ├── 18 │ ├── data.txt │ ├── index.ts │ └── out.txt ├── 19 │ ├── data.txt │ └── index.ts ├── 20 │ ├── data.txt │ └── index.ts ├── 21 │ ├── 21steps-correct.txt │ ├── 21steps-quick.txt │ ├── data.txt │ ├── index.ts │ ├── out-correct.txt │ ├── out.txt │ └── scratch.txt ├── 22 │ ├── data.txt │ └── index.ts ├── 23 │ ├── data.txt │ └── index.ts ├── 24 │ ├── data.txt │ └── index.ts ├── 25 │ ├── data.txt │ └── index.ts ├── 01 │ ├── data.txt │ └── index.ts ├── 02 │ ├── data.txt │ └── index.ts ├── 03 │ ├── data.txt │ └── index.ts ├── 04 │ ├── data.txt │ └── index.ts ├── 05 │ ├── data.txt │ ├── improved_input.txt │ └── index.ts ├── 06 │ ├── data.txt │ └── index.ts ├── 07 │ ├── data.txt │ └── index.ts ├── 08 │ ├── data.txt │ └── index.ts └── 09 │ ├── data.txt │ └── index.ts └── 2024 ├── 10 ├── data.txt └── index.ts ├── 11 ├── data.txt └── index.ts ├── 12 ├── data.txt └── index.ts ├── 13 └── index.ts ├── 14 └── index.ts ├── 15 └── index.ts ├── 16 └── index.ts ├── 17 └── index.ts ├── 18 └── index.ts ├── 19 └── index.ts ├── 20 └── index.ts ├── 21 └── index.ts ├── 22 └── index.ts ├── 23 └── index.ts ├── 24 └── index.ts ├── 25 └── index.ts ├── 01 ├── data.txt └── index.ts ├── 02 ├── data.txt └── index.ts ├── 03 ├── data.txt └── index.ts ├── 04 ├── data.txt └── index.ts ├── 05 ├── data.txt ├── index-bad.ts └── index.ts ├── 06 ├── data.txt └── index.ts ├── 07 ├── data.txt └── index.ts ├── 08 ├── data.txt └── index.ts └── 09 ├── data.txt └── index.ts /.assets/test-output-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/T-Hugs/advent-of-code/12ec661dcea6e4d3c327031023dd14410174d2d1/.assets/test-output-screenshot.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .scratch 3 | ./test.ts 4 | node_modules/ 5 | data.drew.txt -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "tabWidth": 4, 4 | "useTabs": true, 5 | "semi": true, 6 | "singleQuote": false, 7 | "printWidth": 120, 8 | "arrowParens": "avoid" 9 | } 10 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Current TS File", 9 | "type": "node", 10 | "request": "launch", 11 | "args": ["${relativeFile}"], 12 | "runtimeArgs": ["--nolazy", "-r", "ts-node/register"], 13 | "sourceMaps": true, 14 | "cwd": "${workspaceRoot}", 15 | "protocol": "inspector", 16 | "console": "integratedTerminal", 17 | "customDescriptionGenerator": "function (def) { if (this.toString) { const _v = this.toString(); if (_v.indexOf(\"[object Object]\") < 0) return _v; } return def; }" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.insertSpaces": false 3 | } -------------------------------------------------------------------------------- /.vscode/snippets.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | // Place your advent-of-code workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 3 | // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 4 | // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 5 | // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 6 | // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 7 | // Placeholders with the same ids are connected. 8 | // Example: 9 | // "Print to console": { 10 | // "scope": "javascript,typescript", 11 | // "prefix": "log", 12 | // "body": [ 13 | // "console.log('$1');", 14 | // "$2" 15 | // ], 16 | // "description": "Log output to console" 17 | // } 18 | "Test Case": { 19 | "scope": "typescript", 20 | "prefix": "test", 21 | "body": ["{", "\tinput: `$1`,", "\textraArgs: [],", "\texpected: ``,", "\texpectedPart2: ``,", "}"], 22 | "description": "Insert test into tests array" 23 | }, 24 | "Loop input lines": { 25 | "scope": "typescript", 26 | "prefix": "lines", 27 | "body": ["const lines = input.split(\"\\n\");", "for (const line of lines) {", "\t$1", "}"], 28 | "description": "Split input by lines and loop over them" 29 | }, 30 | "Loop input groups": { 31 | "scope": "typescript", 32 | "prefix": "groups", 33 | "body": [ 34 | "const groups = input.split(\"\\n\\n\");", 35 | "for (const group of groups) {", 36 | "\tconst lines = group.split(\"\\n\");", 37 | "\tfor (const line of lines) {", 38 | "\t\t$1", 39 | "\t}", 40 | "}" 41 | ], 42 | "description": "Split input by groups (double line break), then by lines (single line break), and loop over all the lines within each group." 43 | }, 44 | "Create grid from input": { 45 | "scope": "typescript", 46 | "prefix": "grid", 47 | "body": [ 48 | "const grid = new Grid(input);", 49 | "$1" 50 | ], 51 | "description": "Create a grid out of the given text-serialized grid input." 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.zsh_config: -------------------------------------------------------------------------------- 1 | alias run='ts-node ./run.ts' 2 | alias submit='ts-node ./submit.ts' 3 | alias suck='ts-node ./init.ts suck' -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Puzzle data (anything named data.txt) is copyright Eric Wastl, who retains all rights. 2 | Everything else in this repository falls under the license below. 3 | 4 | MIT License 5 | 6 | Copyright (c) 2020 Trevor Gau 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/T-Hugs/advent-of-code/12ec661dcea6e4d3c327031023dd14410174d2d1/bun.lockb -------------------------------------------------------------------------------- /compareTemplate.dat: -------------------------------------------------------------------------------- 1 | import * as util from "../../../util/util"; 2 | import * as test from "../../../util/test"; 3 | import chalk from "chalk"; 4 | import { log, logSolution, trace } from "../../../util/log"; 5 | const { log, logGrid, logSolution, trace } = LOGUTIL; 6 | 7 | const YEAR = {year}; 8 | const DAY = {day}; 9 | 10 | // solution path: {solution_path} 11 | // data path : {data_path} 12 | // problem url : {problem_url} 13 | 14 | async function p{year}day{day}_part1(input: string) { 15 | return "Not implemented"; 16 | } 17 | 18 | async function p{year}day{day}_part2(input: string) { 19 | return "Not implemented"; 20 | } 21 | 22 | async function run() { 23 | const part1tests: TestCase[] = []; 24 | const part2tests: TestCase[] = []; 25 | 26 | // Run tests 27 | test.beginTests(); 28 | test.beginSection(); 29 | for (const testCase of part1tests) { 30 | test.logTestResult(testCase, String(await p{year}day{day}_part1(testCase.input))); 31 | } 32 | test.beginSection(); 33 | for (const testCase of part2tests) { 34 | test.logTestResult(testCase, String(await p{year}day{day}_part2(testCase.input))); 35 | } 36 | test.endTests(); 37 | 38 | // Get input and run program 39 | const input = await util.getInput(DAY, YEAR); 40 | const part1Solution = String(await p{year}day{day}_part1(input)); 41 | const part2Solution = String(await p{year}day{day}_part2(input)); 42 | 43 | logSolution(part1Solution, part2Solution); 44 | } 45 | 46 | run() 47 | .then(() => { 48 | process.exit(); 49 | }) 50 | .catch(error => { 51 | throw error; 52 | }); 53 | -------------------------------------------------------------------------------- /config.ts: -------------------------------------------------------------------------------- 1 | export const UA_STRING = "Mozilla/5.0 (+via {https://github.com/t-hugs/advent-of-code} by {trevorsg@gmail.com})"; -------------------------------------------------------------------------------- /getToken.ts: -------------------------------------------------------------------------------- 1 | import { LocalStorage } from "node-localstorage"; 2 | import { getAppRoot } from "./util/util"; 3 | import path from "path"; 4 | import { log } from "./util/log"; 5 | import chalk from "chalk"; 6 | import _ from "lodash"; 7 | 8 | const appRoot = getAppRoot(); 9 | const localStorage = new LocalStorage(path.join(appRoot, ".scratch")); 10 | 11 | export function getSessionToken() { 12 | const token = localStorage.getItem("sessionToken") 13 | if (!token) { 14 | log(chalk`{bgRed Session token not found! Run npx ts-node login.ts to authenticate to Advent of Code.}`); 15 | process.exit(1); 16 | } 17 | return token; 18 | } -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/T-Hugs/advent-of-code/12ec661dcea6e4d3c327031023dd14410174d2d1/index.ts -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "advent-of-code", 3 | "version": "1.0.0", 4 | "description": "Trevor Gau's solutions to Advent of Code", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/T-Hugs/advent-of-code.git" 12 | }, 13 | "author": "Trevor Gau", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/T-Hugs/advent-of-code/issues" 17 | }, 18 | "homepage": "https://github.com/T-Hugs/advent-of-code#readme", 19 | "dependencies": { 20 | "@types/fast-levenshtein": "^0.0.2", 21 | "@types/inquirer": "^8.1.3", 22 | "@types/lodash": "^4.14.191", 23 | "@types/mkdirp": "^1.0.2", 24 | "@types/node": "^22.10.1", 25 | "@types/node-localstorage": "^1.3.0", 26 | "a-star": "^0.2.0", 27 | "chalk": "^4.1.2", 28 | "core-js": "^3.33.3", 29 | "fast-levenshtein": "^3.0.0", 30 | "inquirer": "^8.0.0", 31 | "js-combinatorics": "^2.1.2", 32 | "lodash": "^4.17.21", 33 | "mkdirp": "^1.0.4", 34 | "node-localstorage": "^2.2.1", 35 | "playwright-chromium": "^1.28.1", 36 | "ts-node": "^10.9.2", 37 | "typescript": "^5.7.2" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /run.ts: -------------------------------------------------------------------------------- 1 | import * as util from "./util/util"; 2 | import path from "path"; 3 | import * as LOGUTIL from "./util/log"; 4 | import * as TESTUTIL from "./util/test"; 5 | import chalk from "chalk"; 6 | const { log } = LOGUTIL; 7 | 8 | let debug = false; 9 | let help = false; 10 | let noTests = false; 11 | let year: number = 0; 12 | let day: number = 0; 13 | 14 | const args = process.argv.slice(2); 15 | for (const arg of args) { 16 | if (arg.trim() === "--debug" || arg.trim() === "-d") { 17 | debug = true; 18 | } else if (arg.trim() === "--help" || arg.trim() === "-h") { 19 | help = true; 20 | } else if (arg.trim() === "--no-test" || arg.trim() === "--no-tests" || arg.trim() === "-n") { 21 | noTests = true; 22 | } else { 23 | const num = Number(arg); 24 | if (Number.isInteger(num)) { 25 | if (num >= 1 && num <= 25) { 26 | day = num; 27 | } else if (num >= 2015 && num < 2100) { 28 | year = num; 29 | } else { 30 | usage(); 31 | } 32 | } else { 33 | usage(); 34 | } 35 | } 36 | } 37 | 38 | if ((year === 0 && day !== 0) || (year !== 0 && day === 0)) { 39 | usage(); 40 | } 41 | 42 | if (help) { 43 | usage(); 44 | } 45 | 46 | LOGUTIL.setDebug(debug); 47 | TESTUTIL.setNoTests(noTests); 48 | 49 | if (year === 0 && day === 0) { 50 | ({ year, day } = util.getLatestPuzzleDate()); 51 | } 52 | const puzzleFile = path.join(util.getDayRoot(day, year), "index"); 53 | log(chalk`\n== Running puzzle {cyan ${year}.${day}}${debug ? " [Debug ON]" : ""} ==\n`); 54 | require(puzzleFile); 55 | 56 | function usage() { 57 | log(` 58 | Runs your solution for the problem for the given . If 59 | executed without arguments, it will attempt to run the most 60 | recently-released Advent of Code puzzle. 61 | 62 | Usage: 63 | ts-node run.ts [ ] 64 | 65 | Arguments: 66 | year: a 4-digit number greater than or equal to 2015 67 | day: a number between 1 and 25, inclusive 68 | 69 | Options: 70 | --help, -h: Show this help message. 71 | --debug, -d: Print debug/trace messages. 72 | --no-tests, -n: Don't run tests. 73 | 74 | Examples: 75 | ts-node run.ts 76 | ts-node run.ts 2018 22 77 | `); 78 | process.exit(0); 79 | } 80 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2022", 4 | "module": "commonjs", 5 | "lib": ["ESNext"], 6 | "noEmit": true, 7 | "strict": true, 8 | "moduleResolution": "node", 9 | "paths": { 10 | "js-combinatorics/commonjs/combinatorics": ["./node_modules/js-combinatorics"] 11 | }, 12 | "typeRoots": ["./node_modules/@types", "./util/@types"], 13 | "types": ["global", "node"], 14 | "esModuleInterop": true, 15 | "skipLibCheck": false, 16 | "forceConsistentCasingInFileNames": true, 17 | "sourceMap": true, 18 | "allowJs": true 19 | }, 20 | "include": ["**/*.ts", "**/*.d.ts"] 21 | } 22 | -------------------------------------------------------------------------------- /util/@types/global/index.d.ts: -------------------------------------------------------------------------------- 1 | interface TestCase { 2 | input: string; 3 | extraArgs?: any[]; 4 | expected: string; 5 | expectedPart1?: string; 6 | expectedPart2?: string; 7 | ignore?: boolean; 8 | } 9 | 10 | type Obj = { [key: string]: TVal }; 11 | 12 | declare module "a-star" { 13 | interface Node { 14 | parent: Node; 15 | data: T 16 | } 17 | interface AStarOptions { 18 | start: T; 19 | isEnd: (node: T) => boolean; 20 | neighbor: (node: T, rawNode: Node) => T[]; 21 | heuristic: (node: T) => number; 22 | distance: (a: T, b: T) => number; 23 | hash?: (node: T) => string; 24 | timeout?: number; 25 | } 26 | export default function (options: AStarOptions): { status: string; path: T[] }; 27 | } 28 | -------------------------------------------------------------------------------- /years/2015/04/data.txt: -------------------------------------------------------------------------------- 1 | iwrupvqb -------------------------------------------------------------------------------- /years/2015/09/data.txt: -------------------------------------------------------------------------------- 1 | Tristram to AlphaCentauri = 34 2 | Tristram to Snowdin = 100 3 | Tristram to Tambi = 63 4 | Tristram to Faerun = 108 5 | Tristram to Norrath = 111 6 | Tristram to Straylight = 89 7 | Tristram to Arbre = 132 8 | AlphaCentauri to Snowdin = 4 9 | AlphaCentauri to Tambi = 79 10 | AlphaCentauri to Faerun = 44 11 | AlphaCentauri to Norrath = 147 12 | AlphaCentauri to Straylight = 133 13 | AlphaCentauri to Arbre = 74 14 | Snowdin to Tambi = 105 15 | Snowdin to Faerun = 95 16 | Snowdin to Norrath = 48 17 | Snowdin to Straylight = 88 18 | Snowdin to Arbre = 7 19 | Tambi to Faerun = 68 20 | Tambi to Norrath = 134 21 | Tambi to Straylight = 107 22 | Tambi to Arbre = 40 23 | Faerun to Norrath = 11 24 | Faerun to Straylight = 66 25 | Faerun to Arbre = 144 26 | Norrath to Straylight = 115 27 | Norrath to Arbre = 135 28 | Straylight to Arbre = 127 -------------------------------------------------------------------------------- /years/2015/10/data.txt: -------------------------------------------------------------------------------- 1 | 1113122113 -------------------------------------------------------------------------------- /years/2015/11/data.txt: -------------------------------------------------------------------------------- 1 | cqjxjnds -------------------------------------------------------------------------------- /years/2015/14/data.txt: -------------------------------------------------------------------------------- 1 | Vixen can fly 8 km/s for 8 seconds, but then must rest for 53 seconds. 2 | Blitzen can fly 13 km/s for 4 seconds, but then must rest for 49 seconds. 3 | Rudolph can fly 20 km/s for 7 seconds, but then must rest for 132 seconds. 4 | Cupid can fly 12 km/s for 4 seconds, but then must rest for 43 seconds. 5 | Donner can fly 9 km/s for 5 seconds, but then must rest for 38 seconds. 6 | Dasher can fly 10 km/s for 4 seconds, but then must rest for 37 seconds. 7 | Comet can fly 3 km/s for 37 seconds, but then must rest for 76 seconds. 8 | Prancer can fly 9 km/s for 12 seconds, but then must rest for 97 seconds. 9 | Dancer can fly 37 km/s for 1 seconds, but then must rest for 36 seconds. -------------------------------------------------------------------------------- /years/2015/15/data.txt: -------------------------------------------------------------------------------- 1 | Sprinkles: capacity 5, durability -1, flavor 0, texture 0, calories 5 2 | PeanutButter: capacity -1, durability 3, flavor 0, texture 0, calories 1 3 | Frosting: capacity 0, durability -1, flavor 4, texture 0, calories 6 4 | Sugar: capacity -1, durability 0, flavor 0, texture 2, calories 8 -------------------------------------------------------------------------------- /years/2015/17/data.txt: -------------------------------------------------------------------------------- 1 | 11 2 | 30 3 | 47 4 | 31 5 | 32 6 | 36 7 | 3 8 | 1 9 | 5 10 | 3 11 | 32 12 | 36 13 | 15 14 | 11 15 | 46 16 | 26 17 | 28 18 | 1 19 | 19 20 | 3 -------------------------------------------------------------------------------- /years/2015/19/data.txt: -------------------------------------------------------------------------------- 1 | Al => ThF 2 | Al => ThRnFAr 3 | B => BCa 4 | B => TiB 5 | B => TiRnFAr 6 | Ca => CaCa 7 | Ca => PB 8 | Ca => PRnFAr 9 | Ca => SiRnFYFAr 10 | Ca => SiRnMgAr 11 | Ca => SiTh 12 | F => CaF 13 | F => PMg 14 | F => SiAl 15 | H => CRnAlAr 16 | H => CRnFYFYFAr 17 | H => CRnFYMgAr 18 | H => CRnMgYFAr 19 | H => HCa 20 | H => NRnFYFAr 21 | H => NRnMgAr 22 | H => NTh 23 | H => OB 24 | H => ORnFAr 25 | Mg => BF 26 | Mg => TiMg 27 | N => CRnFAr 28 | N => HSi 29 | O => CRnFYFAr 30 | O => CRnMgAr 31 | O => HP 32 | O => NRnFAr 33 | O => OTi 34 | P => CaP 35 | P => PTi 36 | P => SiRnFAr 37 | Si => CaSi 38 | Th => ThCa 39 | Ti => BP 40 | Ti => TiTi 41 | e => HF 42 | e => NAl 43 | e => OMg 44 | 45 | CRnSiRnCaPTiMgYCaPTiRnFArSiThFArCaSiThSiThPBCaCaSiRnSiRnTiTiMgArPBCaPMgYPTiRnFArFArCaSiRnBPMgArPRnCaPTiRnFArCaSiThCaCaFArPBCaCaPTiTiRnFArCaSiRnSiAlYSiThRnFArArCaSiRnBFArCaCaSiRnSiThCaCaCaFYCaPTiBCaSiThCaSiThPMgArSiRnCaPBFYCaCaFArCaCaCaCaSiThCaSiRnPRnFArPBSiThPRnFArSiRnMgArCaFYFArCaSiRnSiAlArTiTiTiTiTiTiTiRnPMgArPTiTiTiBSiRnSiAlArTiTiRnPMgArCaFYBPBPTiRnSiRnMgArSiThCaFArCaSiThFArPRnFArCaSiRnTiBSiThSiRnSiAlYCaFArPRnFArSiThCaFArCaCaSiThCaCaCaSiRnPRnCaFArFYPMgArCaPBCaPBSiRnFYPBCaFArCaSiAl -------------------------------------------------------------------------------- /years/2015/20/data.txt: -------------------------------------------------------------------------------- 1 | 29000000 -------------------------------------------------------------------------------- /years/2015/21/data.txt: -------------------------------------------------------------------------------- 1 | Hit Points: 104 2 | Damage: 8 3 | Armor: 1 -------------------------------------------------------------------------------- /years/2015/22/data.txt: -------------------------------------------------------------------------------- 1 | Hit Points: 71 2 | Damage: 10 -------------------------------------------------------------------------------- /years/2015/23/data.txt: -------------------------------------------------------------------------------- 1 | jio a, +19 2 | inc a 3 | tpl a 4 | inc a 5 | tpl a 6 | inc a 7 | tpl a 8 | tpl a 9 | inc a 10 | inc a 11 | tpl a 12 | tpl a 13 | inc a 14 | inc a 15 | tpl a 16 | inc a 17 | inc a 18 | tpl a 19 | jmp +23 20 | tpl a 21 | tpl a 22 | inc a 23 | inc a 24 | tpl a 25 | inc a 26 | inc a 27 | tpl a 28 | inc a 29 | tpl a 30 | inc a 31 | tpl a 32 | inc a 33 | tpl a 34 | inc a 35 | inc a 36 | tpl a 37 | inc a 38 | inc a 39 | tpl a 40 | tpl a 41 | inc a 42 | jio a, +8 43 | inc b 44 | jie a, +4 45 | tpl a 46 | inc a 47 | jmp +2 48 | hlf a 49 | jmp -7 -------------------------------------------------------------------------------- /years/2015/24/data.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 7 5 | 11 6 | 13 7 | 17 8 | 19 9 | 23 10 | 31 11 | 37 12 | 41 13 | 43 14 | 47 15 | 53 16 | 59 17 | 61 18 | 67 19 | 71 20 | 73 21 | 79 22 | 83 23 | 89 24 | 97 25 | 101 26 | 103 27 | 107 28 | 109 29 | 113 -------------------------------------------------------------------------------- /years/2015/25/data.txt: -------------------------------------------------------------------------------- 1 | To continue, please consult the code grid in the manual. Enter the code at row 2978, column 3083. -------------------------------------------------------------------------------- /years/2015/25/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2015; 9 | const DAY = 25; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2015/25/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2015/25/data.txt 13 | // problem url : https://adventofcode.com/2015/day/25 14 | 15 | function getRowColIndex(row: number, col: number) { 16 | const newRow = row + (col - 1); 17 | return (Math.pow(newRow - 1, 2) + (newRow - 1)) / 2 + 1 + (col - 1); 18 | } 19 | 20 | async function p2015day25_part1(input: string) { 21 | const [row, col] = /(\d+).*?(\d+)/.exec(input)!.slice(1, 3).map(Number); 22 | const pwIndex = getRowColIndex(row, col); 23 | const startAt = 20151125; 24 | const mul = 252533; 25 | const div = 33554393; 26 | 27 | // lol slow 28 | let val = startAt; 29 | for (let i = 0; i < pwIndex - 1; ++i) { 30 | val = (val * mul) % div; 31 | } 32 | 33 | return val; 34 | } 35 | 36 | async function run() { 37 | const part1tests: TestCase[] = []; 38 | 39 | // Run tests 40 | test.beginTests(); 41 | test.beginSection(); 42 | for (const testCase of part1tests) { 43 | test.logTestResult(testCase, String(await p2015day25_part1(testCase.input))); 44 | } 45 | test.endTests(); 46 | 47 | // Get input and run program while measuring performance 48 | const input = await util.getInput(DAY, YEAR); 49 | 50 | const part1Before = performance.now(); 51 | const part1Solution = String(await p2015day25_part1(input)); 52 | const part1After = performance.now(); 53 | 54 | logSolution(25, 2015, part1Solution); 55 | 56 | log(chalk.gray("--- Performance ---")); 57 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 58 | log(); 59 | } 60 | 61 | run() 62 | .then(() => { 63 | process.exit(); 64 | }) 65 | .catch(error => { 66 | throw error; 67 | }); 68 | -------------------------------------------------------------------------------- /years/2016/01/data.txt: -------------------------------------------------------------------------------- 1 | L3, R1, L4, L1, L2, R4, L3, L3, R2, R3, L5, R1, R3, L4, L1, L2, R2, R1, L4, L4, R2, L5, R3, R2, R1, L1, L2, R2, R2, L1, L1, R2, R1, L3, L5, R4, L3, R3, R3, L5, L190, L4, R4, R51, L4, R5, R5, R2, L1, L3, R1, R4, L3, R1, R3, L5, L4, R2, R5, R2, L1, L5, L1, L1, R78, L3, R2, L3, R5, L2, R2, R4, L1, L4, R1, R185, R3, L4, L1, L1, L3, R4, L4, L1, R5, L5, L1, R5, L1, R2, L5, L2, R4, R3, L2, R3, R1, L3, L5, L4, R3, L2, L4, L5, L4, R1, L1, R5, L2, R4, R2, R3, L1, L1, L4, L3, R4, L3, L5, R2, L5, L1, L1, R2, R3, L5, L3, L2, L1, L4, R4, R4, L2, R3, R1, L2, R1, L2, L2, R3, R3, L1, R4, L5, L3, R4, R4, R1, L2, L5, L3, R1, R4, L2, R5, R4, R2, L5, L3, R4, R1, L1, R5, L3, R1, R5, L2, R1, L5, L2, R2, L2, L3, R3, R3, R1 2 | -------------------------------------------------------------------------------- /years/2016/05/data.txt: -------------------------------------------------------------------------------- 1 | ojvtpuvg -------------------------------------------------------------------------------- /years/2016/11/data.txt: -------------------------------------------------------------------------------- 1 | The first floor contains a strontium generator, a strontium-compatible microchip, a plutonium generator, and a plutonium-compatible microchip. 2 | The second floor contains a thulium generator, a ruthenium generator, a ruthenium-compatible microchip, a curium generator, and a curium-compatible microchip. 3 | The third floor contains a thulium-compatible microchip. 4 | The fourth floor contains nothing relevant. -------------------------------------------------------------------------------- /years/2016/12/data.txt: -------------------------------------------------------------------------------- 1 | cpy 1 a 2 | cpy 1 b 3 | cpy 26 d 4 | jnz c 2 5 | jnz 1 5 6 | cpy 7 c 7 | inc d 8 | dec c 9 | jnz c -2 10 | cpy a c 11 | inc a 12 | dec b 13 | jnz b -2 14 | cpy c b 15 | dec d 16 | jnz d -6 17 | cpy 18 c 18 | cpy 11 d 19 | inc a 20 | dec d 21 | jnz d -2 22 | dec c 23 | jnz c -5 -------------------------------------------------------------------------------- /years/2016/13/data.txt: -------------------------------------------------------------------------------- 1 | 1352 -------------------------------------------------------------------------------- /years/2016/14/data.txt: -------------------------------------------------------------------------------- 1 | jlmsuwbz -------------------------------------------------------------------------------- /years/2016/15/data.txt: -------------------------------------------------------------------------------- 1 | Disc #1 has 17 positions; at time=0, it is at position 1. 2 | Disc #2 has 7 positions; at time=0, it is at position 0. 3 | Disc #3 has 19 positions; at time=0, it is at position 2. 4 | Disc #4 has 5 positions; at time=0, it is at position 0. 5 | Disc #5 has 3 positions; at time=0, it is at position 0. 6 | Disc #6 has 13 positions; at time=0, it is at position 5. -------------------------------------------------------------------------------- /years/2016/16/data.txt: -------------------------------------------------------------------------------- 1 | 11011110011011101 -------------------------------------------------------------------------------- /years/2016/17/data.txt: -------------------------------------------------------------------------------- 1 | lpvhkcbi -------------------------------------------------------------------------------- /years/2016/18/data.txt: -------------------------------------------------------------------------------- 1 | .^^^^^.^^.^^^.^...^..^^.^.^..^^^^^^^^^^..^...^^.^..^^^^..^^^^...^.^.^^^^^^^^....^..^^^^^^.^^^.^^^.^^ -------------------------------------------------------------------------------- /years/2016/19/data.txt: -------------------------------------------------------------------------------- 1 | 3014603 -------------------------------------------------------------------------------- /years/2016/23/data.txt: -------------------------------------------------------------------------------- 1 | cpy a b 2 | dec b 3 | cpy a d 4 | cpy 0 a 5 | cpy b c 6 | inc a 7 | dec c 8 | jnz c -2 9 | dec d 10 | jnz d -5 11 | dec b 12 | cpy b c 13 | cpy c d 14 | dec d 15 | inc c 16 | jnz d -2 17 | tgl c 18 | cpy -16 c 19 | jnz 1 c 20 | cpy 79 c 21 | jnz 74 d 22 | inc a 23 | inc d 24 | jnz d -2 25 | inc c 26 | jnz c -5 27 | -------------------------------------------------------------------------------- /years/2016/23/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2016; 9 | const DAY = 23; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2016/23/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2016/23/data.txt 13 | // problem url : https://adventofcode.com/2016/day/23 14 | 15 | async function p2016day23_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2016day23_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2016day23_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2016day23_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2016day23_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2016day23_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(23, 2016, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2016/24/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2016; 9 | const DAY = 24; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2016/24/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2016/24/data.txt 13 | // problem url : https://adventofcode.com/2016/day/24 14 | 15 | async function p2016day24_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2016day24_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2016day24_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2016day24_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2016day24_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2016day24_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(24, 2016, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2016/25/data.txt: -------------------------------------------------------------------------------- 1 | cpy a d 2 | cpy 7 c 3 | cpy 365 b 4 | inc d 5 | dec b 6 | jnz b -2 7 | dec c 8 | jnz c -5 9 | cpy d a 10 | jnz 0 0 11 | cpy a b 12 | cpy 0 a 13 | cpy 2 c 14 | jnz b 2 15 | jnz 1 6 16 | dec b 17 | dec c 18 | jnz c -4 19 | inc a 20 | jnz 1 -7 21 | cpy 2 b 22 | jnz c 2 23 | jnz 1 4 24 | dec b 25 | dec c 26 | jnz 1 -4 27 | jnz 0 0 28 | out b 29 | jnz a -19 30 | jnz 1 -21 31 | -------------------------------------------------------------------------------- /years/2016/25/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2016; 9 | const DAY = 25; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2016/25/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2016/25/data.txt 13 | // problem url : https://adventofcode.com/2016/day/25 14 | 15 | async function p2016day25_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2016day25_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2016day25_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2016day25_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2016day25_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2016day25_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(25, 2016, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/01/data.txt: -------------------------------------------------------------------------------- 1 | 7385764686251444473997915123782972536343732657517834671759462795461213782428342931896181695578996274321317419242359534783957372932953774336338118488967172727651862498838195317654289797558683458511126996217953322817229372373455862177844478443391835484591525235651863464891177927244954925827786799436536592561374269299474738321293575385899438446558569241236278779779983587912431395475244796538888373287186921647426866237756737342731976763959499149996315591584716122199183295277439872911371313924594486766479438544417416529743495114819825984524437367225234184772617942525954961136976875325182725754768372684531972614455134523596338355374444273522115362238734383164778129376628621497662965456761631796178353599629887665939521892447361219479646483978798392716119793282717739524897385958273726776318154977675546287789874265339688753977185129334929715486381875286278528247696464162297691698154712775589541945263574897266575996455547625537947927972497979333932115165151462742216327321116291372396585618664475715321298122335789262942284571328414569375464386446824882551918843185195829547373915482687534432942778312542752798313434628498295216692646713137244198123219531693559848915834623825919191532658735422176965451741869666714874158492556445954852299161868651448123825821775363219246244515946392686275545561989355573946924767442253465342753995764791927951158771231944177692469531494559697911176613943396258141822244578457498361352381518166587583342233816989329544415621127397996723997397219676486966684729653763525768655324443991129862129181215339947555257279592921258246646215764736698583211625887436176149251356452358211458343439374688341116529726972434697324734525114192229641464227986582845477741747787673588848439713619326889624326944553386782821633538775371915973899959295232927996742218926514374168947582441892731462993481877277714436887597223871881149693228928442427611664655772333471893735932419937832937953495929514837663883938416644387342825836673733778119481514427512453357628396666791547531814844176342696362416842993761919369994779897357348334197721735231299249116477 -------------------------------------------------------------------------------- /years/2017/01/index.ts: -------------------------------------------------------------------------------- 1 | import * as util from "../../../util/util"; 2 | import chalk from "chalk"; 3 | import { log, logSolution, trace } from "../../../util/log"; 4 | 5 | const YEAR = 2017; 6 | const DAY = 1; 7 | 8 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/01/index.ts 9 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/01/data.txt 10 | // problem url : https://adventofcode.com/2017/day/1 11 | 12 | async function p2017day1_part1(input: string) { 13 | let sum = 0; 14 | for (let i = 0; i < input.length; ++i) { 15 | let dig = input[i]; 16 | let next = i === input.length - 1 ? input[0] : input[i + 1]; 17 | if (dig === next) { 18 | sum += parseInt(dig, 10); 19 | } 20 | } 21 | return sum; 22 | } 23 | 24 | async function p2017day1_part2(input: string, part1Solution: string) { 25 | let sum = 0; 26 | for (let i = 0; i < input.length; ++i) { 27 | let dig = input[i]; 28 | let next = input[(i + input.length / 2) % input.length]; 29 | if (dig === next) { 30 | sum += parseInt(dig, 10); 31 | } 32 | } 33 | return sum; 34 | } 35 | 36 | async function run() { 37 | const input = await util.getInput(DAY, YEAR); 38 | 39 | const part1Solution = String(await p2017day1_part1(input)); 40 | const part2Solution = String(await p2017day1_part2(input, part1Solution)); 41 | 42 | logSolution(1, 2017, part1Solution, part2Solution); 43 | } 44 | 45 | run() 46 | .then(() => { 47 | process.exit(); 48 | }) 49 | .catch(error => { 50 | throw error; 51 | }); 52 | -------------------------------------------------------------------------------- /years/2017/02/data.txt: -------------------------------------------------------------------------------- 1 | 1236 741 557 1029 144 101 1968 2159 1399 80 1139 1167 1695 82 90 2236 2 | 2134 106 107 1025 584 619 191 496 80 352 351 2267 1983 1973 97 1244 3 | 3227 179 691 3177 172 1636 3781 2020 3339 2337 189 3516 1500 176 159 3279 4 | 201 688 364 180 586 659 623 577 188 265 403 670 195 720 115 37 5 | 1892 1664 2737 2676 849 2514 923 171 311 218 255 2787 1271 188 1278 2834 6 | 150 3276 204 603 3130 587 3363 3306 2890 127 176 174 383 3309 213 1620 7 | 5903 3686 200 230 6040 4675 6266 179 5375 1069 283 82 6210 6626 6398 1954 8 | 942 2324 1901 213 125 2518 655 189 2499 160 2841 2646 198 173 1841 200 9 | 232 45 272 280 44 248 50 266 296 297 236 254 58 212 276 48 10 | 563 768 124 267 153 622 199 591 204 125 93 656 198 164 797 506 11 | 243 4746 1785 204 568 4228 2701 4303 188 4148 4831 1557 4692 166 4210 3656 12 | 72 514 1572 172 1197 750 1392 1647 1587 183 1484 213 1614 718 177 622 13 | 1117 97 2758 2484 941 1854 1074 264 2494 83 1434 96 2067 2825 2160 92 14 | 2610 1290 204 2265 1374 2581 185 852 207 175 3308 1500 2898 1120 1892 3074 15 | 2322 1434 301 2156 98 2194 587 1416 1521 94 1985 424 91 119 1869 1073 16 | 66 87 176 107 2791 109 21 92 3016 2239 1708 3175 3210 2842 446 484 17 | -------------------------------------------------------------------------------- /years/2017/02/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 2; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/02/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/02/data.txt 13 | // problem url : https://adventofcode.com/2017/day/2 14 | 15 | async function p2017day2_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day2_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day2_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day2_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day2_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day2_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(2, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/03/data.txt: -------------------------------------------------------------------------------- 1 | 361527 2 | -------------------------------------------------------------------------------- /years/2017/03/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 3; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/03/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/03/data.txt 13 | // problem url : https://adventofcode.com/2017/day/3 14 | 15 | async function p2017day3_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day3_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day3_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day3_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day3_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day3_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(3, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/04/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 4; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/04/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/04/data.txt 13 | // problem url : https://adventofcode.com/2017/day/4 14 | 15 | async function p2017day4_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day4_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day4_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day4_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day4_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day4_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(4, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/05/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 5; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/05/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/05/data.txt 13 | // problem url : https://adventofcode.com/2017/day/5 14 | 15 | async function p2017day5_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day5_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day5_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day5_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day5_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day5_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(5, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/06/data.txt: -------------------------------------------------------------------------------- 1 | 2 8 8 5 4 2 3 1 5 5 1 2 15 13 5 14 2 | -------------------------------------------------------------------------------- /years/2017/06/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 6; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/06/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/06/data.txt 13 | // problem url : https://adventofcode.com/2017/day/6 14 | 15 | async function p2017day6_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day6_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day6_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day6_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day6_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day6_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(6, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/07/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 7; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/07/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/07/data.txt 13 | // problem url : https://adventofcode.com/2017/day/7 14 | 15 | async function p2017day7_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day7_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day7_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day7_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day7_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day7_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(7, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/08/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 8; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/08/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/08/data.txt 13 | // problem url : https://adventofcode.com/2017/day/8 14 | 15 | async function p2017day8_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day8_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day8_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day8_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day8_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day8_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(8, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/09/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 9; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/09/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/09/data.txt 13 | // problem url : https://adventofcode.com/2017/day/9 14 | 15 | async function p2017day9_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day9_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day9_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day9_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day9_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day9_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(9, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/10/data.txt: -------------------------------------------------------------------------------- 1 | 199,0,255,136,174,254,227,16,51,85,1,2,22,17,7,192 2 | -------------------------------------------------------------------------------- /years/2017/10/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 10; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/10/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/10/data.txt 13 | // problem url : https://adventofcode.com/2017/day/10 14 | 15 | async function p2017day10_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day10_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day10_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day10_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day10_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day10_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(10, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/11/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 11; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/11/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/11/data.txt 13 | // problem url : https://adventofcode.com/2017/day/11 14 | 15 | async function p2017day11_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day11_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day11_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day11_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day11_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day11_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(11, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/12/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 12; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/12/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/12/data.txt 13 | // problem url : https://adventofcode.com/2017/day/12 14 | 15 | async function p2017day12_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day12_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day12_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day12_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day12_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day12_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(12, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/13/data.txt: -------------------------------------------------------------------------------- 1 | 0: 3 2 | 1: 2 3 | 2: 4 4 | 4: 4 5 | 6: 5 6 | 8: 8 7 | 10: 6 8 | 12: 6 9 | 14: 6 10 | 16: 6 11 | 18: 8 12 | 20: 8 13 | 22: 12 14 | 24: 10 15 | 26: 9 16 | 28: 8 17 | 30: 8 18 | 32: 12 19 | 34: 12 20 | 36: 12 21 | 38: 12 22 | 40: 8 23 | 42: 12 24 | 44: 14 25 | 46: 14 26 | 48: 10 27 | 50: 12 28 | 52: 12 29 | 54: 14 30 | 56: 14 31 | 58: 14 32 | 62: 12 33 | 64: 14 34 | 66: 14 35 | 68: 14 36 | 70: 12 37 | 74: 14 38 | 76: 14 39 | 78: 14 40 | 80: 18 41 | 82: 17 42 | 84: 30 43 | 88: 14 44 | -------------------------------------------------------------------------------- /years/2017/13/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 13; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/13/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/13/data.txt 13 | // problem url : https://adventofcode.com/2017/day/13 14 | 15 | async function p2017day13_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day13_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day13_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day13_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day13_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day13_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(13, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/14/data.txt: -------------------------------------------------------------------------------- 1 | hfdlxzhv 2 | -------------------------------------------------------------------------------- /years/2017/14/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 14; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/14/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/14/data.txt 13 | // problem url : https://adventofcode.com/2017/day/14 14 | 15 | async function p2017day14_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day14_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day14_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day14_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day14_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day14_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(14, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/15/data.txt: -------------------------------------------------------------------------------- 1 | Generator A starts with 783 2 | Generator B starts with 325 3 | -------------------------------------------------------------------------------- /years/2017/15/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 15; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/15/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/15/data.txt 13 | // problem url : https://adventofcode.com/2017/day/15 14 | 15 | async function p2017day15_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day15_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day15_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day15_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day15_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day15_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(15, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/16/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 16; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/16/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/16/data.txt 13 | // problem url : https://adventofcode.com/2017/day/16 14 | 15 | async function p2017day16_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day16_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day16_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day16_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day16_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day16_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(16, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/17/data.txt: -------------------------------------------------------------------------------- 1 | 356 2 | -------------------------------------------------------------------------------- /years/2017/17/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 17; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/17/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/17/data.txt 13 | // problem url : https://adventofcode.com/2017/day/17 14 | 15 | async function p2017day17_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day17_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day17_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day17_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day17_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day17_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(17, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/18/data.txt: -------------------------------------------------------------------------------- 1 | set i 31 2 | set a 1 3 | mul p 17 4 | jgz p p 5 | mul a 2 6 | add i -1 7 | jgz i -2 8 | add a -1 9 | set i 127 10 | set p 464 11 | mul p 8505 12 | mod p a 13 | mul p 129749 14 | add p 12345 15 | mod p a 16 | set b p 17 | mod b 10000 18 | snd b 19 | add i -1 20 | jgz i -9 21 | jgz a 3 22 | rcv b 23 | jgz b -1 24 | set f 0 25 | set i 126 26 | rcv a 27 | rcv b 28 | set p a 29 | mul p -1 30 | add p b 31 | jgz p 4 32 | snd a 33 | set a b 34 | jgz 1 3 35 | snd b 36 | set f 1 37 | add i -1 38 | jgz i -11 39 | snd a 40 | jgz f -16 41 | jgz a -19 42 | -------------------------------------------------------------------------------- /years/2017/18/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 18; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/18/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/18/data.txt 13 | // problem url : https://adventofcode.com/2017/day/18 14 | 15 | async function p2017day18_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day18_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day18_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day18_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day18_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day18_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(18, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/19/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 19; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/19/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/19/data.txt 13 | // problem url : https://adventofcode.com/2017/day/19 14 | 15 | async function p2017day19_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day19_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day19_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day19_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day19_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day19_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(19, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/20/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 20; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/20/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/20/data.txt 13 | // problem url : https://adventofcode.com/2017/day/20 14 | 15 | async function p2017day20_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day20_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day20_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day20_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day20_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day20_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(20, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/21/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 21; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/21/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/21/data.txt 13 | // problem url : https://adventofcode.com/2017/day/21 14 | 15 | async function p2017day21_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day21_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day21_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day21_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day21_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day21_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(21, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/22/data.txt: -------------------------------------------------------------------------------- 1 | #.#...###.#.##.#....##.## 2 | ..####.#.######....#....# 3 | ###..###.#.###.##.##..#.# 4 | ...##.....##.###.##.###.. 5 | ....#...##.##..#....###.. 6 | ##.#..###.#.###......#### 7 | #.#.###...###..#.#.#.#.#. 8 | ###...##..##..#..##...... 9 | ##.#.####.#..###....#.### 10 | .....#..###....######..## 11 | .##.#.###....#..#####..#. 12 | ########...##.##....##..# 13 | .#.###.##.#..#..#.#..##.. 14 | .#.##.##....##....##.#.#. 15 | ..#.#.##.#..##..##.#..#.# 16 | .####..#..#.###..#..#..#. 17 | #.#.##......##..#.....### 18 | ...####...#.#.##.....#### 19 | #..##..##..#.####.#.#..#. 20 | #...###.##..###..#..#.... 21 | #..#....##.##.....###..## 22 | #..##...#...##...####..#. 23 | #.###..#.#####.#..#..###. 24 | ###.#...#.##..#..#...##.# 25 | .#...#..#.#.#.##.####.... 26 | -------------------------------------------------------------------------------- /years/2017/22/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 22; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/22/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/22/data.txt 13 | // problem url : https://adventofcode.com/2017/day/22 14 | 15 | async function p2017day22_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day22_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day22_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day22_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day22_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day22_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(22, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/23/data.txt: -------------------------------------------------------------------------------- 1 | set b 84 2 | set c b 3 | jnz a 2 4 | jnz 1 5 5 | mul b 100 6 | sub b -100000 7 | set c b 8 | sub c -17000 9 | set f 1 10 | set d 2 11 | set e 2 12 | set g d 13 | mul g e 14 | sub g b 15 | jnz g 2 16 | set f 0 17 | sub e -1 18 | set g e 19 | sub g b 20 | jnz g -8 21 | sub d -1 22 | set g d 23 | sub g b 24 | jnz g -13 25 | jnz f 2 26 | sub h -1 27 | set g b 28 | sub g c 29 | jnz g 2 30 | jnz 1 3 31 | sub b -17 32 | jnz 1 -23 33 | -------------------------------------------------------------------------------- /years/2017/23/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 23; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/23/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/23/data.txt 13 | // problem url : https://adventofcode.com/2017/day/23 14 | 15 | async function p2017day23_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day23_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day23_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day23_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day23_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day23_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(23, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/24/data.txt: -------------------------------------------------------------------------------- 1 | 31/13 2 | 34/4 3 | 49/49 4 | 23/37 5 | 47/45 6 | 32/4 7 | 12/35 8 | 37/30 9 | 41/48 10 | 0/47 11 | 32/30 12 | 12/5 13 | 37/31 14 | 7/41 15 | 10/28 16 | 35/4 17 | 28/35 18 | 20/29 19 | 32/20 20 | 31/43 21 | 48/14 22 | 10/11 23 | 27/6 24 | 9/24 25 | 8/28 26 | 45/48 27 | 8/1 28 | 16/19 29 | 45/45 30 | 0/4 31 | 29/33 32 | 2/5 33 | 33/9 34 | 11/7 35 | 32/10 36 | 44/1 37 | 40/32 38 | 2/45 39 | 16/16 40 | 1/18 41 | 38/36 42 | 34/24 43 | 39/44 44 | 32/37 45 | 26/46 46 | 25/33 47 | 9/10 48 | 0/29 49 | 38/8 50 | 33/33 51 | 49/19 52 | 18/20 53 | 49/39 54 | 18/39 55 | 26/13 56 | 19/32 57 | -------------------------------------------------------------------------------- /years/2017/24/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 24; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/24/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/24/data.txt 13 | // problem url : https://adventofcode.com/2017/day/24 14 | 15 | async function p2017day24_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day24_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day24_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day24_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day24_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day24_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(24, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2017/25/data.txt: -------------------------------------------------------------------------------- 1 | Begin in state A. 2 | Perform a diagnostic checksum after 12629077 steps. 3 | 4 | In state A: 5 | If the current value is 0: 6 | - Write the value 1. 7 | - Move one slot to the right. 8 | - Continue with state B. 9 | If the current value is 1: 10 | - Write the value 0. 11 | - Move one slot to the left. 12 | - Continue with state B. 13 | 14 | In state B: 15 | If the current value is 0: 16 | - Write the value 0. 17 | - Move one slot to the right. 18 | - Continue with state C. 19 | If the current value is 1: 20 | - Write the value 1. 21 | - Move one slot to the left. 22 | - Continue with state B. 23 | 24 | In state C: 25 | If the current value is 0: 26 | - Write the value 1. 27 | - Move one slot to the right. 28 | - Continue with state D. 29 | If the current value is 1: 30 | - Write the value 0. 31 | - Move one slot to the left. 32 | - Continue with state A. 33 | 34 | In state D: 35 | If the current value is 0: 36 | - Write the value 1. 37 | - Move one slot to the left. 38 | - Continue with state E. 39 | If the current value is 1: 40 | - Write the value 1. 41 | - Move one slot to the left. 42 | - Continue with state F. 43 | 44 | In state E: 45 | If the current value is 0: 46 | - Write the value 1. 47 | - Move one slot to the left. 48 | - Continue with state A. 49 | If the current value is 1: 50 | - Write the value 0. 51 | - Move one slot to the left. 52 | - Continue with state D. 53 | 54 | In state F: 55 | If the current value is 0: 56 | - Write the value 1. 57 | - Move one slot to the right. 58 | - Continue with state A. 59 | If the current value is 1: 60 | - Write the value 1. 61 | - Move one slot to the left. 62 | - Continue with state E. 63 | -------------------------------------------------------------------------------- /years/2017/25/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2017; 9 | const DAY = 25; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2017/25/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2017/25/data.txt 13 | // problem url : https://adventofcode.com/2017/day/25 14 | 15 | async function p2017day25_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2017day25_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2017day25_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2017day25_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2017day25_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2017day25_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(25, 2017, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/01/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 1; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/01/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/01/data.txt 13 | // problem url : https://adventofcode.com/2018/day/1 14 | 15 | async function p2018day1_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day1_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day1_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day1_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day1_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day1_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(1, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/02/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 2; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/02/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/02/data.txt 13 | // problem url : https://adventofcode.com/2018/day/2 14 | 15 | async function p2018day2_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day2_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day2_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day2_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day2_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day2_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(2, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/03/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 3; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/03/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/03/data.txt 13 | // problem url : https://adventofcode.com/2018/day/3 14 | 15 | async function p2018day3_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day3_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day3_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day3_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day3_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day3_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(3, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/04/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 4; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/04/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/04/data.txt 13 | // problem url : https://adventofcode.com/2018/day/4 14 | 15 | async function p2018day4_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day4_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day4_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day4_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day4_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day4_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(4, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/05/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 5; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/05/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/05/data.txt 13 | // problem url : https://adventofcode.com/2018/day/5 14 | 15 | async function p2018day5_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day5_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day5_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day5_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day5_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day5_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(5, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/06/data.txt: -------------------------------------------------------------------------------- 1 | 137, 140 2 | 318, 75 3 | 205, 290 4 | 104, 141 5 | 163, 104 6 | 169, 164 7 | 238, 324 8 | 180, 166 9 | 260, 198 10 | 189, 139 11 | 290, 49 12 | 51, 350 13 | 51, 299 14 | 73, 324 15 | 220, 171 16 | 146, 336 17 | 167, 286 18 | 51, 254 19 | 40, 135 20 | 103, 138 21 | 100, 271 22 | 104, 328 23 | 80, 67 24 | 199, 180 25 | 320, 262 26 | 215, 290 27 | 96, 142 28 | 314, 128 29 | 162, 106 30 | 214, 326 31 | 303, 267 32 | 340, 96 33 | 211, 278 34 | 335, 250 35 | 41, 194 36 | 229, 291 37 | 45, 97 38 | 304, 208 39 | 198, 214 40 | 250, 80 41 | 200, 51 42 | 287, 50 43 | 120, 234 44 | 106, 311 45 | 41, 116 46 | 359, 152 47 | 189, 207 48 | 300, 167 49 | 318, 315 50 | 296, 72 51 | -------------------------------------------------------------------------------- /years/2018/06/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 6; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/06/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/06/data.txt 13 | // problem url : https://adventofcode.com/2018/day/6 14 | 15 | async function p2018day6_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day6_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day6_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day6_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day6_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day6_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(6, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/07/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 7; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/07/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/07/data.txt 13 | // problem url : https://adventofcode.com/2018/day/7 14 | 15 | async function p2018day7_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day7_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day7_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day7_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day7_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day7_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(7, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/08/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 8; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/08/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/08/data.txt 13 | // problem url : https://adventofcode.com/2018/day/8 14 | 15 | async function p2018day8_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day8_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day8_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day8_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day8_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day8_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(8, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/09/data.txt: -------------------------------------------------------------------------------- 1 | 493 players; last marble is worth 71863 points 2 | -------------------------------------------------------------------------------- /years/2018/09/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 9; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/09/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/09/data.txt 13 | // problem url : https://adventofcode.com/2018/day/9 14 | 15 | async function p2018day9_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day9_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day9_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day9_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day9_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day9_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(9, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/10/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 10; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/10/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/10/data.txt 13 | // problem url : https://adventofcode.com/2018/day/10 14 | 15 | async function p2018day10_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day10_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day10_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day10_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day10_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day10_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(10, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/11/data.txt: -------------------------------------------------------------------------------- 1 | 3463 2 | -------------------------------------------------------------------------------- /years/2018/11/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 11; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/11/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/11/data.txt 13 | // problem url : https://adventofcode.com/2018/day/11 14 | 15 | async function p2018day11_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day11_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day11_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day11_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day11_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day11_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(11, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/12/data.txt: -------------------------------------------------------------------------------- 1 | initial state: #.#####.##.###...#...#.####..#..#.#....##.###.##...#####.#..##.#..##..#..#.#.#.#....#.####....#..# 2 | 3 | #.#.. => . 4 | ..### => . 5 | ...## => . 6 | .#### => # 7 | .###. => # 8 | #.... => . 9 | #.#.# => . 10 | ###.. => # 11 | #..#. => . 12 | ##### => # 13 | .##.# => # 14 | .#... => . 15 | ##.## => # 16 | #...# => # 17 | .#.## => . 18 | ##..# => . 19 | ..... => . 20 | .#.#. => # 21 | #.### => # 22 | ....# => . 23 | ...#. => # 24 | ..#.# => # 25 | ##... => # 26 | ####. => # 27 | #..## => # 28 | ##.#. => # 29 | ###.# => . 30 | #.##. => . 31 | ..#.. => # 32 | .#..# => . 33 | ..##. => . 34 | .##.. => # 35 | -------------------------------------------------------------------------------- /years/2018/12/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 12; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/12/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/12/data.txt 13 | // problem url : https://adventofcode.com/2018/day/12 14 | 15 | async function p2018day12_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day12_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day12_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day12_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day12_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day12_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(12, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/13/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 13; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/13/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/13/data.txt 13 | // problem url : https://adventofcode.com/2018/day/13 14 | 15 | async function p2018day13_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day13_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day13_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day13_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day13_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day13_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(13, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/14/data.txt: -------------------------------------------------------------------------------- 1 | 290431 2 | -------------------------------------------------------------------------------- /years/2018/14/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 14; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/14/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/14/data.txt 13 | // problem url : https://adventofcode.com/2018/day/14 14 | 15 | async function p2018day14_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day14_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day14_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day14_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day14_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day14_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(14, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/15/data.txt: -------------------------------------------------------------------------------- 1 | ################################ 2 | ########.####################### 3 | #######..####################### 4 | ######..######################## 5 | ###....####...################## 6 | ###.#..####G..################## 7 | ###G#.G#####..####G############# 8 | ##....G..###.......############# 9 | #G#####...#..G.....############# 10 | #G.###..#..G........############ 11 | #..G.G..........G.....#.G.###### 12 | ###......GG..G............###### 13 | #######....G..#####.G...#.###### 14 | #######......#######....######## 15 | #######.....#########..........# 16 | #######.....#########.........## 17 | #######...#.#########.........## 18 | #######.....#########........### 19 | #######.....#########.........## 20 | #######....E.#######........#..# 21 | #######.......#####E........#### 22 | ###.#.E..#.....G.........#..#### 23 | ###......#E......E..G...E...#### 24 | ##...........#.............##### 25 | #####.###..............E...##### 26 | #############..............##### 27 | #############..E.....###...##### 28 | ###############..E...###...##### 29 | #################.E#.####..##### 30 | #################..#.########### 31 | #################..#.########### 32 | ################################ 33 | -------------------------------------------------------------------------------- /years/2018/15/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 15; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/15/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/15/data.txt 13 | // problem url : https://adventofcode.com/2018/day/15 14 | 15 | async function p2018day15_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day15_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day15_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day15_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day15_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day15_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(15, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/16/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 16; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/16/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/16/data.txt 13 | // problem url : https://adventofcode.com/2018/day/16 14 | 15 | async function p2018day16_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day16_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day16_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day16_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day16_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day16_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(16, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/17/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 17; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/17/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/17/data.txt 13 | // problem url : https://adventofcode.com/2018/day/17 14 | 15 | async function p2018day17_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day17_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day17_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day17_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day17_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day17_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(17, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/18/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 18; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/18/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/18/data.txt 13 | // problem url : https://adventofcode.com/2018/day/18 14 | 15 | async function p2018day18_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day18_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day18_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day18_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day18_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day18_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(18, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/19/data.txt: -------------------------------------------------------------------------------- 1 | #ip 5 2 | addi 5 16 5 3 | seti 1 8 3 4 | seti 1 1 1 5 | mulr 3 1 4 6 | eqrr 4 2 4 7 | addr 4 5 5 8 | addi 5 1 5 9 | addr 3 0 0 10 | addi 1 1 1 11 | gtrr 1 2 4 12 | addr 5 4 5 13 | seti 2 7 5 14 | addi 3 1 3 15 | gtrr 3 2 4 16 | addr 4 5 5 17 | seti 1 5 5 18 | mulr 5 5 5 19 | addi 2 2 2 20 | mulr 2 2 2 21 | mulr 5 2 2 22 | muli 2 11 2 23 | addi 4 8 4 24 | mulr 4 5 4 25 | addi 4 20 4 26 | addr 2 4 2 27 | addr 5 0 5 28 | seti 0 4 5 29 | setr 5 8 4 30 | mulr 4 5 4 31 | addr 5 4 4 32 | mulr 5 4 4 33 | muli 4 14 4 34 | mulr 4 5 4 35 | addr 2 4 2 36 | seti 0 7 0 37 | seti 0 9 5 38 | -------------------------------------------------------------------------------- /years/2018/19/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 19; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/19/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/19/data.txt 13 | // problem url : https://adventofcode.com/2018/day/19 14 | 15 | async function p2018day19_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day19_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day19_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day19_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day19_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day19_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(19, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/20/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 20; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/20/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/20/data.txt 13 | // problem url : https://adventofcode.com/2018/day/20 14 | 15 | async function p2018day20_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day20_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day20_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day20_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day20_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day20_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(20, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/21/data.txt: -------------------------------------------------------------------------------- 1 | #ip 3 2 | seti 123 0 5 3 | bani 5 456 5 4 | eqri 5 72 5 5 | addr 5 3 3 6 | seti 0 0 3 7 | seti 0 3 5 8 | bori 5 65536 4 9 | seti 8858047 4 5 10 | bani 4 255 2 11 | addr 5 2 5 12 | bani 5 16777215 5 13 | muli 5 65899 5 14 | bani 5 16777215 5 15 | gtir 256 4 2 16 | addr 2 3 3 17 | addi 3 1 3 18 | seti 27 5 3 19 | seti 0 6 2 20 | addi 2 1 1 21 | muli 1 256 1 22 | gtrr 1 4 1 23 | addr 1 3 3 24 | addi 3 1 3 25 | seti 25 1 3 26 | addi 2 1 2 27 | seti 17 4 3 28 | setr 2 1 4 29 | seti 7 3 3 30 | eqrr 5 0 2 31 | addr 2 3 3 32 | seti 5 2 3 33 | -------------------------------------------------------------------------------- /years/2018/21/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 21; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/21/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/21/data.txt 13 | // problem url : https://adventofcode.com/2018/day/21 14 | 15 | async function p2018day21_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day21_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day21_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day21_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day21_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day21_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(21, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/22/data.txt: -------------------------------------------------------------------------------- 1 | depth: 4002 2 | target: 5,746 3 | -------------------------------------------------------------------------------- /years/2018/22/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 22; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/22/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/22/data.txt 13 | // problem url : https://adventofcode.com/2018/day/22 14 | 15 | async function p2018day22_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day22_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day22_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day22_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day22_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day22_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(22, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/23/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 23; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/23/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/23/data.txt 13 | // problem url : https://adventofcode.com/2018/day/23 14 | 15 | async function p2018day23_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day23_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day23_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day23_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day23_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day23_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(23, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/24/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 24; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/24/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/24/data.txt 13 | // problem url : https://adventofcode.com/2018/day/24 14 | 15 | async function p2018day24_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day24_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day24_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day24_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day24_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day24_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(24, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2018/25/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2018; 9 | const DAY = 25; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2018/25/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2018/25/data.txt 13 | // problem url : https://adventofcode.com/2018/day/25 14 | 15 | async function p2018day25_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2018day25_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2018day25_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2018day25_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2018day25_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2018day25_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(25, 2018, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/01/data.txt: -------------------------------------------------------------------------------- 1 | 51753 2 | 53456 3 | 128133 4 | 118219 5 | 136490 6 | 113318 7 | 134001 8 | 99775 9 | 84746 10 | 68712 11 | 104274 12 | 72530 13 | 101517 14 | 65533 15 | 98719 16 | 100215 17 | 144296 18 | 114166 19 | 62930 20 | 118494 21 | 144800 22 | 97604 23 | 112836 24 | 73074 25 | 62591 26 | 99278 27 | 94544 28 | 73035 29 | 146631 30 | 148331 31 | 144573 32 | 121956 33 | 94088 34 | 60092 35 | 126397 36 | 117285 37 | 122292 38 | 77413 39 | 145860 40 | 76968 41 | 64790 42 | 58479 43 | 94035 44 | 148441 45 | 78999 46 | 74329 47 | 145182 48 | 129497 49 | 106765 50 | 67046 51 | 58702 52 | 123344 53 | 63866 54 | 121123 55 | 126808 56 | 115190 57 | 86467 58 | 136359 59 | 148718 60 | 88225 61 | 126185 62 | 82745 63 | 142546 64 | 149788 65 | 137524 66 | 114690 67 | 68075 68 | 60244 69 | 127157 70 | 123719 71 | 87843 72 | 107714 73 | 51281 74 | 92123 75 | 146495 76 | 50761 77 | 130708 78 | 53103 79 | 75289 80 | 121675 81 | 61726 82 | 70674 83 | 101755 84 | 97736 85 | 100141 86 | 81085 87 | 55493 88 | 73071 89 | 85321 90 | 119965 91 | 147313 92 | 105201 93 | 107107 94 | 130007 95 | 67834 96 | 137614 97 | 140848 98 | 64038 99 | 106078 100 | 71447 -------------------------------------------------------------------------------- /years/2019/02/data.txt: -------------------------------------------------------------------------------- 1 | 1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,9,19,1,10,19,23,2,9,23,27,1,6,27,31,2,31,9,35,1,5,35,39,1,10,39,43,1,10,43,47,2,13,47,51,1,10,51,55,2,55,10,59,1,9,59,63,2,6,63,67,1,5,67,71,1,71,5,75,1,5,75,79,2,79,13,83,1,83,5,87,2,6,87,91,1,5,91,95,1,95,9,99,1,99,6,103,1,103,13,107,1,107,5,111,2,111,13,115,1,115,6,119,1,6,119,123,2,123,13,127,1,10,127,131,1,131,2,135,1,135,5,0,99,2,14,0,0 -------------------------------------------------------------------------------- /years/2019/04/data.txt: -------------------------------------------------------------------------------- 1 | 206938-679128 -------------------------------------------------------------------------------- /years/2019/04/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 4; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/04/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/04/data.txt 13 | // problem url : https://adventofcode.com/2019/day/4 14 | 15 | async function p2019day4_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day4_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day4_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day4_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day4_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day4_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(4, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/05/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 5; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/05/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/05/data.txt 13 | // problem url : https://adventofcode.com/2019/day/5 14 | 15 | async function p2019day5_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day5_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day5_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day5_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day5_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day5_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(5, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/06/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 6; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/06/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/06/data.txt 13 | // problem url : https://adventofcode.com/2019/day/6 14 | 15 | async function p2019day6_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day6_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day6_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day6_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day6_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day6_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(6, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/07/data.txt: -------------------------------------------------------------------------------- 1 | 3,8,1001,8,10,8,105,1,0,0,21,30,39,64,81,102,183,264,345,426,99999,3,9,1001,9,2,9,4,9,99,3,9,1002,9,4,9,4,9,99,3,9,1002,9,5,9,101,2,9,9,102,3,9,9,1001,9,2,9,1002,9,2,9,4,9,99,3,9,1002,9,3,9,1001,9,5,9,1002,9,3,9,4,9,99,3,9,102,4,9,9,1001,9,3,9,102,4,9,9,1001,9,5,9,4,9,99,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,1,9,9,4,9,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,99,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,101,1,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,99,3,9,101,1,9,9,4,9,3,9,101,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,99,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,99,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,101,1,9,9,4,9,99 -------------------------------------------------------------------------------- /years/2019/07/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 7; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/07/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/07/data.txt 13 | // problem url : https://adventofcode.com/2019/day/7 14 | 15 | async function p2019day7_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day7_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day7_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day7_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day7_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day7_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(7, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/08/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 8; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/08/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/08/data.txt 13 | // problem url : https://adventofcode.com/2019/day/8 14 | 15 | async function p2019day8_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day8_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day8_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day8_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day8_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day8_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(8, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/09/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 9; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/09/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/09/data.txt 13 | // problem url : https://adventofcode.com/2019/day/9 14 | 15 | async function p2019day9_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day9_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day9_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day9_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day9_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day9_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(9, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/10/data.txt: -------------------------------------------------------------------------------- 1 | #.#.##..#.###...##.#....##....### 2 | ...#..#.#.##.....#..##.#...###..# 3 | ####...#..#.##...#.##..####..#.#. 4 | ..#.#..#...#..####.##....#..####. 5 | ....##...#.##...#.#.#...#.#..##.. 6 | .#....#.##.#.##......#..#..#..#.. 7 | .#.......#.....#.....#...###..... 8 | #.#.#.##..#.#...###.#.###....#..# 9 | #.#..........##..###.......#...## 10 | #.#.........##...##.#.##..####..# 11 | ###.#..#####...#..#.#...#..#.#... 12 | .##.#.##.........####.#.#...##... 13 | ..##...#..###.....#.#...#.#..#.## 14 | .#...#.....#....##...##...###...# 15 | ###...#..#....#............#..... 16 | .#####.#......#.......#.#.##..#.# 17 | #.#......#.#.#.#.......##..##..## 18 | .#.##...##..#..##...##...##.....# 19 | #.#...#.#.#.#.#..#...#...##...#.# 20 | ##.#..#....#..##.#.#....#.##...## 21 | ...###.#.#.......#.#..#..#...#.## 22 | .....##......#.....#..###.....##. 23 | ........##..#.#........##.......# 24 | #.##.##...##..###.#....#....###.# 25 | ..##.##....##.#..#.##..#.....#... 26 | .#.#....##..###.#...##.#.#.#..#.. 27 | ..#..##.##.#.##....#...#......... 28 | #...#.#.#....#.......#.#...#..#.# 29 | ...###.##.#...#..#...##...##....# 30 | ...#..#.#.#..#####...#.#...####.# 31 | ##.#...#..##..#..###.#..........# 32 | ..........#..##..#..###...#..#... 33 | .#.##...#....##.....#.#...##...## -------------------------------------------------------------------------------- /years/2019/10/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 10; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/10/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/10/data.txt 13 | // problem url : https://adventofcode.com/2019/day/10 14 | 15 | async function p2019day10_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day10_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day10_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day10_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day10_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day10_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(10, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/11/data.txt: -------------------------------------------------------------------------------- 1 | 3,8,1005,8,319,1106,0,11,0,0,0,104,1,104,0,3,8,102,-1,8,10,1001,10,1,10,4,10,108,1,8,10,4,10,101,0,8,28,2,1105,12,10,1006,0,12,3,8,102,-1,8,10,101,1,10,10,4,10,1008,8,0,10,4,10,102,1,8,58,2,107,7,10,1006,0,38,2,1008,3,10,3,8,1002,8,-1,10,1001,10,1,10,4,10,108,0,8,10,4,10,1001,8,0,90,3,8,1002,8,-1,10,101,1,10,10,4,10,108,0,8,10,4,10,101,0,8,112,1006,0,65,1,1103,1,10,1006,0,91,3,8,102,-1,8,10,101,1,10,10,4,10,108,1,8,10,4,10,101,0,8,144,1006,0,32,3,8,1002,8,-1,10,101,1,10,10,4,10,108,1,8,10,4,10,102,1,8,169,1,109,12,10,1006,0,96,1006,0,5,3,8,102,-1,8,10,1001,10,1,10,4,10,108,1,8,10,4,10,101,0,8,201,3,8,102,-1,8,10,1001,10,1,10,4,10,108,0,8,10,4,10,1001,8,0,223,1,4,9,10,2,8,5,10,1,3,4,10,3,8,1002,8,-1,10,1001,10,1,10,4,10,108,1,8,10,4,10,101,0,8,257,1,1,9,10,1006,0,87,3,8,102,-1,8,10,1001,10,1,10,4,10,1008,8,0,10,4,10,102,1,8,287,2,1105,20,10,1,1006,3,10,1,3,4,10,101,1,9,9,1007,9,1002,10,1005,10,15,99,109,641,104,0,104,1,21102,1,932972962600,1,21101,0,336,0,1106,0,440,21101,838483681940,0,1,21101,0,347,0,1106,0,440,3,10,104,0,104,1,3,10,104,0,104,0,3,10,104,0,104,1,3,10,104,0,104,1,3,10,104,0,104,0,3,10,104,0,104,1,21101,3375393987,0,1,21101,394,0,0,1105,1,440,21102,46174071847,1,1,21102,1,405,0,1106,0,440,3,10,104,0,104,0,3,10,104,0,104,0,21101,988648461076,0,1,21101,428,0,0,1106,0,440,21101,0,709580452200,1,21101,439,0,0,1105,1,440,99,109,2,22101,0,-1,1,21101,40,0,2,21102,1,471,3,21102,461,1,0,1106,0,504,109,-2,2106,0,0,0,1,0,0,1,109,2,3,10,204,-1,1001,466,467,482,4,0,1001,466,1,466,108,4,466,10,1006,10,498,1102,0,1,466,109,-2,2105,1,0,0,109,4,1202,-1,1,503,1207,-3,0,10,1006,10,521,21102,1,0,-3,22102,1,-3,1,21201,-2,0,2,21101,0,1,3,21102,540,1,0,1106,0,545,109,-4,2106,0,0,109,5,1207,-3,1,10,1006,10,568,2207,-4,-2,10,1006,10,568,22101,0,-4,-4,1105,1,636,22102,1,-4,1,21201,-3,-1,2,21202,-2,2,3,21102,1,587,0,1105,1,545,22101,0,1,-4,21102,1,1,-1,2207,-4,-2,10,1006,10,606,21101,0,0,-1,22202,-2,-1,-2,2107,0,-3,10,1006,10,628,21201,-1,0,1,21101,0,628,0,106,0,503,21202,-2,-1,-2,22201,-4,-2,-4,109,-5,2106,0,0 -------------------------------------------------------------------------------- /years/2019/11/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 11; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/11/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/11/data.txt 13 | // problem url : https://adventofcode.com/2019/day/11 14 | 15 | async function p2019day11_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day11_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day11_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day11_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day11_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day11_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(11, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/12/data.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /years/2019/12/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 12; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/12/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/12/data.txt 13 | // problem url : https://adventofcode.com/2019/day/12 14 | 15 | async function p2019day12_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day12_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day12_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day12_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day12_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day12_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(12, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/13/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 13; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/13/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/13/data.txt 13 | // problem url : https://adventofcode.com/2019/day/13 14 | 15 | async function p2019day13_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day13_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day13_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day13_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day13_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day13_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(13, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/14/data.txt: -------------------------------------------------------------------------------- 1 | 4 BFNQL => 9 LMCRF 2 | 2 XGWNS, 7 TCRNC => 5 TPZCH 3 | 4 RKHMQ, 1 QHRG, 5 JDSNJ => 4 XGWNS 4 | 6 HWTBC, 4 XGWNS => 6 CWCD 5 | 1 BKPZH, 2 FLZX => 9 HWFQG 6 | 1 GDVD, 2 HTSW => 8 CNQW 7 | 2 RMDG => 9 RKHMQ 8 | 3 RTLHZ => 3 MSKWT 9 | 1 QLNHG, 1 RJHCP => 3 GRDJ 10 | 10 DLSD, 2 SWKHJ, 15 HTSW => 1 TCRNC 11 | 4 SWKHJ, 24 ZHDSD, 2 DLSD => 3 CPGJ 12 | 1 SWKHJ => 1 THJHK 13 | 129 ORE => 8 KLSMQ 14 | 3 SLNKW, 4 RTLHZ => 4 LPVGC 15 | 1 SLNKW => 5 RLGFX 16 | 2 QHRG, 1 SGMK => 8 RJHCP 17 | 9 RGKCF, 7 QHRG => 6 ZHDSD 18 | 8 XGWNS, 1 CPGJ => 2 QLNHG 19 | 2 MQFJF, 7 TBVH, 7 FZXS => 2 WZMRW 20 | 13 ZHDSD, 11 SLNKW, 18 RJHCP => 2 CZJR 21 | 1 CNQW, 5 GRDJ, 3 GDVD => 4 FLZX 22 | 129 ORE => 4 RHSHR 23 | 2 HWTBC, 2 JDSNJ => 8 QPBHG 24 | 1 BKPZH, 8 SWKHJ => 6 WSWBV 25 | 8 RJHCP, 7 FRGJK => 1 GSDT 26 | 6 QPBHG => 4 BKPZH 27 | 17 PCRQV, 6 BFNQL, 9 GSDT, 10 MQDHX, 1 ZHDSD, 1 GRDJ, 14 BRGXB, 3 RTLHZ => 8 CFGK 28 | 8 RMDG => 6 SGMK 29 | 3 CZJR => 8 RTLHZ 30 | 3 BFRTV => 7 RGKCF 31 | 6 FRGJK, 8 CZJR, 4 GRDJ => 4 BRGXB 32 | 4 VRVGB => 7 PCRQV 33 | 4 TCRNC, 1 TBVH, 2 FZXS, 1 BQGM, 1 THJHK, 19 RLGFX => 2 CRJTJ 34 | 5 RDNJK => 6 SWKHJ 35 | 2 FLVC, 2 SLNKW, 30 HWTBC => 8 DLSD 36 | 6 TBVH, 3 ZHDSD => 5 BQGM 37 | 17 RLGFX => 4 SCZQN 38 | 8 SWKHJ => 6 FZXS 39 | 9 LZHZ => 3 QDCL 40 | 2 ZHDSD => 1 RDNJK 41 | 15 FZXS, 3 TPZCH => 6 MQFJF 42 | 12 RLGFX, 9 QPBHG, 6 HTSW => 1 BFNQL 43 | 150 ORE => 9 BFRTV 44 | 2 BFRTV, 2 KLSMQ => 2 RMDG 45 | 4 VFLNM, 30 RKHMQ, 4 CRJTJ, 24 CFGK, 21 SCZQN, 4 BMGBG, 9 HWFQG, 34 CWCD, 7 LPVGC, 10 QDCL, 2 WSWBV, 2 WTZX => 1 FUEL 46 | 6 RHSHR, 3 RGKCF, 1 QHRG => 6 JDSNJ 47 | 3 MQDHX, 2 XGWNS, 12 GRDJ => 9 LZHZ 48 | 128 ORE => 6 ZBWLC 49 | 9 JDSNJ, 7 RMDG => 8 FLVC 50 | 4 DLSD, 12 CZJR, 3 MSKWT => 4 MQDHX 51 | 2 BXNX, 4 ZBWLC => 3 QHRG 52 | 19 LMCRF, 3 JDSNJ => 2 BMGBG 53 | 1 RJHCP, 26 SGMK => 9 HTSW 54 | 2 QPBHG => 8 VFLNM 55 | 2 RGKCF => 9 SLNKW 56 | 3 LZHZ, 2 GRDJ => 2 TBVH 57 | 100 ORE => 2 BXNX 58 | 4 DLSD, 21 JDSNJ => 8 GDVD 59 | 2 QHRG => 2 HWTBC 60 | 1 LPVGC, 8 XGWNS => 8 FRGJK 61 | 9 FZXS => 7 VRVGB 62 | 7 WZMRW, 1 TBVH, 1 VFLNM, 8 CNQW, 15 LZHZ, 25 PCRQV, 2 BRGXB => 4 WTZX -------------------------------------------------------------------------------- /years/2019/14/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 14; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/14/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/14/data.txt 13 | // problem url : https://adventofcode.com/2019/day/14 14 | 15 | async function p2019day14_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day14_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day14_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day14_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day14_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day14_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(14, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/15/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 15; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/15/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/15/data.txt 13 | // problem url : https://adventofcode.com/2019/day/15 14 | 15 | async function p2019day15_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day15_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day15_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day15_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day15_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day15_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(15, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/16/data.txt: -------------------------------------------------------------------------------- 1 | 59766832516471105169175836985633322599038555617788874561522148661927081324685821180654682056538815716097295567894852186929107230155154324411726945819817338647442140954601202408433492208282774032110720183977662097053534778395687521636381457489415906710702497357756337246719713103659349031567298436163261681422438462663511427616685223080744010014937551976673341714897682634253850270219462445161703240957568807600494579282412972591613629025720312652350445062631757413159623885481128914333982571503540357043736821931054029305931122179293220911720263006705242490442826574028623201238659548887822088996956559517179003476743001815465428992906356931239533104 -------------------------------------------------------------------------------- /years/2019/16/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 16; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/16/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/16/data.txt 13 | // problem url : https://adventofcode.com/2019/day/16 14 | 15 | async function p2019day16_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day16_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day16_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day16_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day16_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day16_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(16, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/17/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 17; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/17/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/17/data.txt 13 | // problem url : https://adventofcode.com/2019/day/17 14 | 15 | async function p2019day17_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day17_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day17_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day17_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day17_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day17_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(17, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/18/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 18; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/18/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/18/data.txt 13 | // problem url : https://adventofcode.com/2019/day/18 14 | 15 | async function p2019day18_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day18_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day18_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day18_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day18_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day18_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(18, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/19/data.txt: -------------------------------------------------------------------------------- 1 | 109,424,203,1,21102,1,11,0,1106,0,282,21101,18,0,0,1105,1,259,2101,0,1,221,203,1,21101,0,31,0,1105,1,282,21101,38,0,0,1105,1,259,21001,23,0,2,22101,0,1,3,21102,1,1,1,21101,57,0,0,1106,0,303,2102,1,1,222,20102,1,221,3,20102,1,221,2,21101,0,259,1,21102,80,1,0,1105,1,225,21102,1,130,2,21102,1,91,0,1106,0,303,2101,0,1,223,21002,222,1,4,21102,259,1,3,21102,1,225,2,21101,0,225,1,21102,1,118,0,1106,0,225,21002,222,1,3,21101,0,106,2,21102,1,133,0,1106,0,303,21202,1,-1,1,22001,223,1,1,21101,148,0,0,1105,1,259,2102,1,1,223,20101,0,221,4,20102,1,222,3,21102,1,19,2,1001,132,-2,224,1002,224,2,224,1001,224,3,224,1002,132,-1,132,1,224,132,224,21001,224,1,1,21101,195,0,0,106,0,109,20207,1,223,2,20101,0,23,1,21102,-1,1,3,21101,0,214,0,1105,1,303,22101,1,1,1,204,1,99,0,0,0,0,109,5,1201,-4,0,249,21201,-3,0,1,21202,-2,1,2,21201,-1,0,3,21102,1,250,0,1105,1,225,22102,1,1,-4,109,-5,2106,0,0,109,3,22107,0,-2,-1,21202,-1,2,-1,21201,-1,-1,-1,22202,-1,-2,-2,109,-3,2106,0,0,109,3,21207,-2,0,-1,1206,-1,294,104,0,99,21201,-2,0,-2,109,-3,2105,1,0,109,5,22207,-3,-4,-1,1206,-1,346,22201,-4,-3,-4,21202,-3,-1,-1,22201,-4,-1,2,21202,2,-1,-1,22201,-4,-1,1,22102,1,-2,3,21102,343,1,0,1105,1,303,1105,1,415,22207,-2,-3,-1,1206,-1,387,22201,-3,-2,-3,21202,-2,-1,-1,22201,-3,-1,3,21202,3,-1,-1,22201,-3,-1,2,21201,-4,0,1,21101,384,0,0,1106,0,303,1106,0,415,21202,-4,-1,-4,22201,-4,-3,-4,22202,-3,-2,-2,22202,-2,-4,-4,22202,-3,-2,-3,21202,-4,-1,-2,22201,-3,-2,1,21201,1,0,-4,109,-5,2106,0,0 -------------------------------------------------------------------------------- /years/2019/19/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 19; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/19/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/19/data.txt 13 | // problem url : https://adventofcode.com/2019/day/19 14 | 15 | async function p2019day19_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day19_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day19_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day19_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day19_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day19_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(19, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/20/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 20; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/20/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/20/data.txt 13 | // problem url : https://adventofcode.com/2019/day/20 14 | 15 | async function p2019day20_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day20_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day20_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day20_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day20_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day20_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(20, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/21/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2019; 9 | const DAY = 21; 10 | 11 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2019/21/index.ts 12 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2019/21/data.txt 13 | // problem url : https://adventofcode.com/2019/day/21 14 | 15 | async function p2019day21_part1(input: string) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2019day21_part2(input: string) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | test.beginSection(); 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2019day21_part1(testCase.input))); 32 | } 33 | test.beginSection(); 34 | for (const testCase of part2tests) { 35 | test.logTestResult(testCase, String(await p2019day21_part2(testCase.input))); 36 | } 37 | test.endTests(); 38 | 39 | // Get input and run program while measuring performance 40 | const input = await util.getInput(DAY, YEAR); 41 | 42 | const part1Before = performance.now(); 43 | const part1Solution = String(await p2019day21_part1(input)); 44 | const part1After = performance.now(); 45 | 46 | const part2Before = performance.now() 47 | const part2Solution = String(await p2019day21_part2(input)); 48 | const part2After = performance.now(); 49 | 50 | logSolution(21, 2019, part1Solution, part2Solution); 51 | 52 | log(chalk.gray("--- Performance ---")); 53 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 54 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 55 | log(); 56 | } 57 | 58 | run() 59 | .then(() => { 60 | process.exit(); 61 | }) 62 | .catch(error => { 63 | throw error; 64 | }); 65 | -------------------------------------------------------------------------------- /years/2019/22/data.txt: -------------------------------------------------------------------------------- 1 | cut 4753 2 | deal with increment 64 3 | cut 9347 4 | deal with increment 64 5 | cut 4913 6 | deal with increment 33 7 | cut 6371 8 | deal with increment 53 9 | cut -7660 10 | deal with increment 65 11 | cut 7992 12 | deal with increment 29 13 | cut 7979 14 | deal with increment 28 15 | cut -6056 16 | deal with increment 5 17 | cut -3096 18 | deal with increment 13 19 | cut -4315 20 | deal with increment 52 21 | cut 2048 22 | deal into new stack 23 | cut 9126 24 | deal with increment 67 25 | deal into new stack 26 | cut -4398 27 | deal with increment 29 28 | cut 5230 29 | deal with increment 30 30 | cut 1150 31 | deal with increment 41 32 | cut 668 33 | deal into new stack 34 | cut -7265 35 | deal with increment 69 36 | deal into new stack 37 | deal with increment 38 38 | cut -8498 39 | deal with increment 68 40 | deal into new stack 41 | deal with increment 30 42 | cut -1108 43 | deal with increment 7 44 | cut 5875 45 | deal with increment 13 46 | cut -8614 47 | deal with increment 44 48 | cut -9866 49 | deal with increment 2 50 | cut 2582 51 | deal with increment 43 52 | cut 6628 53 | deal with increment 59 54 | deal into new stack 55 | cut 7514 56 | deal into new stack 57 | cut -115 58 | deal with increment 14 59 | cut 2844 60 | deal with increment 4 61 | cut 6564 62 | deal with increment 23 63 | cut -8148 64 | deal with increment 12 65 | cut -81 66 | deal with increment 2 67 | cut 9928 68 | deal with increment 8 69 | cut 3174 70 | deal with increment 28 71 | deal into new stack 72 | cut 6259 73 | deal with increment 3 74 | cut 1863 75 | deal with increment 34 76 | deal into new stack 77 | cut 4751 78 | deal into new stack 79 | cut -7394 80 | deal with increment 59 81 | deal into new stack 82 | deal with increment 28 83 | deal into new stack 84 | deal with increment 59 85 | cut -848 86 | deal with increment 19 87 | deal into new stack 88 | cut -575 89 | deal with increment 60 90 | deal into new stack 91 | deal with increment 74 92 | cut 514 93 | deal into new stack 94 | cut 8660 95 | deal with increment 3 96 | cut 5325 97 | deal with increment 41 98 | deal into new stack 99 | deal with increment 10 100 | deal into new stack -------------------------------------------------------------------------------- /years/2019/24/data.txt: -------------------------------------------------------------------------------- 1 | ..##. 2 | #.... 3 | ..... 4 | #.#.# 5 | #..#. -------------------------------------------------------------------------------- /years/2020/01/data.txt: -------------------------------------------------------------------------------- 1 | 1975 2 | 1600 3 | 113 4 | 1773 5 | 1782 6 | 1680 7 | 1386 8 | 1682 9 | 1991 10 | 1640 11 | 1760 12 | 1236 13 | 1159 14 | 1259 15 | 1279 16 | 1739 17 | 1826 18 | 1888 19 | 1072 20 | 416 21 | 1632 22 | 1656 23 | 1273 24 | 1631 25 | 1079 26 | 1807 27 | 1292 28 | 1128 29 | 1841 30 | 1915 31 | 1619 32 | 1230 33 | 1950 34 | 1627 35 | 1966 36 | 774 37 | 1425 38 | 1983 39 | 1616 40 | 1633 41 | 1559 42 | 1925 43 | 960 44 | 1407 45 | 1708 46 | 1211 47 | 1666 48 | 1910 49 | 1960 50 | 1125 51 | 1242 52 | 1884 53 | 1829 54 | 1881 55 | 1585 56 | 1731 57 | 1753 58 | 1784 59 | 1095 60 | 1267 61 | 1756 62 | 1226 63 | 1107 64 | 1664 65 | 1710 66 | 2000 67 | 1181 68 | 1997 69 | 1607 70 | 1889 71 | 1613 72 | 1859 73 | 1479 74 | 1763 75 | 1692 76 | 1967 77 | 522 78 | 1719 79 | 1816 80 | 1714 81 | 1331 82 | 1976 83 | 1160 84 | 1899 85 | 1906 86 | 1783 87 | 1061 88 | 2006 89 | 1993 90 | 1717 91 | 2009 92 | 1563 93 | 1733 94 | 1866 95 | 1651 96 | 1437 97 | 1517 98 | 1113 99 | 1743 100 | 1240 101 | 1629 102 | 1868 103 | 1912 104 | 1296 105 | 1873 106 | 1673 107 | 1996 108 | 1814 109 | 1215 110 | 1927 111 | 1956 112 | 1970 113 | 1887 114 | 1702 115 | 1495 116 | 1754 117 | 1621 118 | 1055 119 | 1538 120 | 1693 121 | 1840 122 | 1685 123 | 1752 124 | 1933 125 | 1727 126 | 1648 127 | 1792 128 | 1734 129 | 1305 130 | 1446 131 | 1764 132 | 1890 133 | 1904 134 | 1560 135 | 1698 136 | 1645 137 | 1214 138 | 1516 139 | 1064 140 | 1729 141 | 1835 142 | 1642 143 | 1932 144 | 1683 145 | 962 146 | 1081 147 | 1943 148 | 1502 149 | 1622 150 | 196 151 | 1972 152 | 1916 153 | 1850 154 | 1205 155 | 1971 156 | 1937 157 | 1575 158 | 1401 159 | 1351 160 | 2005 161 | 1917 162 | 1670 163 | 1388 164 | 1051 165 | 1941 166 | 1751 167 | 1169 168 | 510 169 | 217 170 | 1948 171 | 1120 172 | 1635 173 | 1636 174 | 1511 175 | 1691 176 | 1589 177 | 1410 178 | 1902 179 | 1572 180 | 1871 181 | 1423 182 | 1114 183 | 1806 184 | 1282 185 | 1193 186 | 1974 187 | 388 188 | 1398 189 | 1992 190 | 1263 191 | 1786 192 | 1723 193 | 1206 194 | 1363 195 | 1177 196 | 1646 197 | 1231 198 | 1140 199 | 1088 200 | 1322 -------------------------------------------------------------------------------- /years/2020/10/data.txt: -------------------------------------------------------------------------------- 1 | 8 2 | 40 3 | 45 4 | 93 5 | 147 6 | 64 7 | 90 8 | 125 9 | 149 10 | 145 11 | 111 12 | 126 13 | 9 14 | 146 15 | 38 16 | 97 17 | 103 18 | 6 19 | 122 20 | 34 21 | 18 22 | 35 23 | 96 24 | 86 25 | 116 26 | 29 27 | 59 28 | 118 29 | 102 30 | 26 31 | 66 32 | 17 33 | 74 34 | 94 35 | 5 36 | 114 37 | 128 38 | 1 39 | 75 40 | 47 41 | 141 42 | 58 43 | 65 44 | 100 45 | 63 46 | 12 47 | 53 48 | 25 49 | 106 50 | 136 51 | 15 52 | 82 53 | 22 54 | 117 55 | 2 56 | 80 57 | 79 58 | 139 59 | 7 60 | 81 61 | 129 62 | 19 63 | 52 64 | 87 65 | 115 66 | 132 67 | 140 68 | 88 69 | 109 70 | 62 71 | 73 72 | 46 73 | 24 74 | 69 75 | 101 76 | 110 77 | 16 78 | 95 79 | 148 80 | 76 81 | 135 82 | 142 83 | 89 84 | 50 85 | 72 86 | 41 87 | 39 88 | 42 89 | 56 90 | 51 91 | 57 92 | 127 93 | 83 94 | 121 95 | 33 96 | 32 97 | 23 -------------------------------------------------------------------------------- /years/2020/13/data.txt: -------------------------------------------------------------------------------- 1 | 1000510 2 | 19,x,x,x,x,x,x,x,x,41,x,x,x,x,x,x,x,x,x,523,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,17,13,x,x,x,x,x,x,x,x,x,x,29,x,853,x,x,x,x,x,37,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,23 -------------------------------------------------------------------------------- /years/2020/15/data.txt: -------------------------------------------------------------------------------- 1 | 18,11,9,0,5,1 -------------------------------------------------------------------------------- /years/2020/17/data.txt: -------------------------------------------------------------------------------- 1 | ##...#.# 2 | ####.#.# 3 | #...#### 4 | ..#.#.#. 5 | ####.#.. 6 | #.#.#..# 7 | .####.## 8 | ..#...## -------------------------------------------------------------------------------- /years/2020/22/data.txt: -------------------------------------------------------------------------------- 1 | Player 1: 2 | 48 3 | 23 4 | 9 5 | 34 6 | 37 7 | 36 8 | 40 9 | 26 10 | 49 11 | 7 12 | 12 13 | 20 14 | 6 15 | 45 16 | 14 17 | 42 18 | 18 19 | 31 20 | 39 21 | 47 22 | 44 23 | 15 24 | 43 25 | 10 26 | 35 27 | 28 | Player 2: 29 | 13 30 | 19 31 | 21 32 | 32 33 | 27 34 | 16 35 | 11 36 | 29 37 | 41 38 | 46 39 | 33 40 | 1 41 | 30 42 | 22 43 | 38 44 | 5 45 | 17 46 | 4 47 | 50 48 | 2 49 | 3 50 | 28 51 | 8 52 | 25 53 | 24 -------------------------------------------------------------------------------- /years/2020/23/data.txt: -------------------------------------------------------------------------------- 1 | 123487596 -------------------------------------------------------------------------------- /years/2020/25/data.txt: -------------------------------------------------------------------------------- 1 | 19774466 2 | 7290641 -------------------------------------------------------------------------------- /years/2020/25/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | import { createDelete } from "typescript"; 8 | 9 | const YEAR = 2020; 10 | const DAY = 25; 11 | 12 | // solution path: /Users/trevorsg/t-hugs/advent-of-code/years/2020/25/index.ts 13 | // data path : /Users/trevorsg/t-hugs/advent-of-code/years/2020/25/data.txt 14 | // problem url : https://adventofcode.com/2020/day/25 15 | 16 | async function p2020day25_part1(input: string) { 17 | const [card, door] = input.split("\n").map(Number); 18 | 19 | const subject = 7; 20 | const mod = 20201227; 21 | 22 | let v = 1; 23 | let cardLoop = 0; 24 | 25 | for (let i = 0; ; ++i) { 26 | v = util.mod(v * subject, mod); 27 | if (v === card) { 28 | cardLoop = i + 1; 29 | break; 30 | } 31 | } 32 | 33 | let key = 1; 34 | for (let i = 0; i < cardLoop; ++i) { 35 | key = util.mod(key * door, mod); 36 | } 37 | return key; 38 | } 39 | 40 | async function run() { 41 | const part1tests: TestCase[] = []; 42 | const part2tests: TestCase[] = []; 43 | 44 | // Run tests 45 | test.beginTests(); 46 | test.beginSection(); 47 | for (const testCase of part1tests) { 48 | test.logTestResult(testCase, String(await p2020day25_part1(testCase.input))); 49 | } 50 | test.endTests(); 51 | 52 | // Get input and run program while measuring performance 53 | const input = await util.getInput(DAY, YEAR); 54 | 55 | const part1Before = performance.now(); 56 | const part1Solution = String(await p2020day25_part1(input)); 57 | const part1After = performance.now(); 58 | 59 | logSolution(25, 2020, part1Solution); 60 | 61 | log(chalk.gray("--- Performance ---")); 62 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 63 | log(); 64 | } 65 | 66 | run() 67 | .then(() => { 68 | process.exit(); 69 | }) 70 | .catch(error => { 71 | throw error; 72 | }); 73 | -------------------------------------------------------------------------------- /years/2021/06/data.txt: -------------------------------------------------------------------------------- 1 | 1,4,1,1,1,1,5,1,1,5,1,4,2,5,1,2,3,1,1,1,1,5,4,2,1,1,3,1,1,1,1,1,1,1,2,1,1,1,1,1,5,1,1,1,1,1,1,1,1,1,4,1,1,1,1,5,1,4,1,1,4,1,1,1,1,4,1,1,5,5,1,1,1,4,1,1,1,1,1,3,2,1,1,1,1,1,2,3,1,1,2,1,1,1,3,1,1,1,2,1,2,1,1,2,1,1,3,1,1,1,3,3,5,1,4,1,1,5,1,1,4,1,5,3,3,5,1,1,1,4,1,1,1,1,1,1,5,5,1,1,4,1,2,1,1,1,1,2,2,2,1,1,2,2,4,1,1,1,1,3,1,2,3,4,1,1,1,4,4,1,1,1,1,1,1,1,4,2,5,2,1,1,4,1,1,5,1,1,5,1,5,5,1,3,5,1,1,5,1,1,2,2,1,1,1,1,1,1,1,4,3,1,1,4,1,4,1,1,1,1,4,1,4,4,4,3,1,1,3,2,1,1,1,1,1,1,1,4,1,3,1,1,1,1,1,1,1,5,2,4,2,1,4,4,1,5,1,1,3,1,3,1,1,1,1,1,4,2,3,2,1,1,2,1,5,2,1,1,4,1,4,1,1,1,4,4,1,1,1,1,1,1,4,1,1,1,2,1,1,2 -------------------------------------------------------------------------------- /years/2021/11/data.txt: -------------------------------------------------------------------------------- 1 | 4743378318 2 | 4664212844 3 | 2535667884 4 | 3273363861 5 | 2282432612 6 | 2166612134 7 | 3776334513 8 | 8123852583 9 | 8181786685 10 | 4362533174 -------------------------------------------------------------------------------- /years/2021/12/data.txt: -------------------------------------------------------------------------------- 1 | ln-nr 2 | ln-wy 3 | fl-XI 4 | qc-start 5 | qq-wy 6 | qc-ln 7 | ZD-nr 8 | qc-YN 9 | XI-wy 10 | ln-qq 11 | ln-XI 12 | YN-start 13 | qq-XI 14 | nr-XI 15 | start-qq 16 | qq-qc 17 | end-XI 18 | qq-YN 19 | ln-YN 20 | end-wy 21 | qc-nr 22 | end-nr -------------------------------------------------------------------------------- /years/2021/14/data.txt: -------------------------------------------------------------------------------- 1 | KKOSPHCNOCHHHSPOBKVF 2 | 3 | NV -> S 4 | OK -> K 5 | SO -> N 6 | FN -> F 7 | NB -> K 8 | BV -> K 9 | PN -> V 10 | KC -> C 11 | HF -> N 12 | CK -> S 13 | VP -> H 14 | SK -> C 15 | NO -> F 16 | PB -> O 17 | PF -> P 18 | VC -> C 19 | OB -> S 20 | VF -> F 21 | BP -> P 22 | HO -> O 23 | FF -> S 24 | NF -> B 25 | KK -> C 26 | OC -> P 27 | OV -> B 28 | NK -> B 29 | KO -> C 30 | OH -> F 31 | CV -> F 32 | CH -> K 33 | SC -> O 34 | BN -> B 35 | HS -> O 36 | VK -> V 37 | PV -> S 38 | BO -> F 39 | OO -> S 40 | KB -> N 41 | NS -> S 42 | BF -> N 43 | SH -> F 44 | SB -> S 45 | PP -> F 46 | KN -> H 47 | BB -> C 48 | SS -> V 49 | HP -> O 50 | PK -> P 51 | HK -> O 52 | FH -> O 53 | BC -> N 54 | FK -> K 55 | HN -> P 56 | CC -> V 57 | FO -> F 58 | FP -> C 59 | VO -> N 60 | SF -> B 61 | HC -> O 62 | NN -> K 63 | FC -> C 64 | CS -> O 65 | FV -> P 66 | HV -> V 67 | PO -> H 68 | BH -> F 69 | OF -> P 70 | PC -> V 71 | CN -> O 72 | HB -> N 73 | CF -> P 74 | HH -> K 75 | VH -> H 76 | OP -> F 77 | BK -> S 78 | SP -> V 79 | BS -> V 80 | VB -> C 81 | NH -> H 82 | SN -> K 83 | KH -> F 84 | OS -> N 85 | NP -> P 86 | VN -> V 87 | KV -> F 88 | KP -> B 89 | VS -> F 90 | NC -> F 91 | ON -> S 92 | FB -> C 93 | SV -> O 94 | PS -> K 95 | KF -> H 96 | CP -> H 97 | FS -> V 98 | VV -> H 99 | CB -> P 100 | PH -> N 101 | CO -> N 102 | KS -> K -------------------------------------------------------------------------------- /years/2021/16/data.txt: -------------------------------------------------------------------------------- 1 | 220D69802BE00A0803711E1441B1006E39C318A12730C200DCE66D2CCE360FA0055652CD32966E3004677EDF600B0803B1361741510076254138D8A00E4FFF3E3393ABE4FC7AC10410010799D2A4430003764DBE281802F3102CA00D4840198430EE0E00021D04E3F41F84AE0154DFDE65A17CCBFAFA14ADA56854FE5E3FD5BCC53B0D2598027A00848C63F2B918C7E513DEC3290051B3867E009CCC5FE46BD520007FE5E8AD344B37583D0803E40085475887144C01A8C10FE2B9803B0720D45A3004652FD8FA05F80122CAF91E5F50E66BEF8AB000BB0F4802039C20917B920B9221200ABF0017B9C92CCDC76BD3A8C4012CCB13CB22CDB243E9C3D2002067440400D9BE62DAC4D2DC0249BF76B6F72BE459B279F759AE7BE42E0058801CC059B08018A0070012CEC045BA01006C03A8000D46C02FA000A8EA007200800E00618018E00410034220061801D36BF178C01796FC52B4017100763547E86000084C7E8910AC0027E9B029FE2F4952F96D81B34C8400C24AA8CDAF4F1E98027C00FACDE3BA86982570D13AA640195CD67B046F004662711E989C468C01F1007A10C4C8320008742287117C401A8C715A3FC2C8EB3777540048272DFE7DE1C0149AC8BC9E79D63200B674013978E8BE5E3A2E9AA3CCDD538C01193CFAB0A146006AA00087C3E88B130401D8E304A239802F39FAC922C0169EA3248DF2D600247C89BCDFE9CA7FFD8BB49686236C9FF9795D80C0139BEC4D6C017978CF78C5EB981FCE7D4D801FA9FB63B14789534584010B5802F3467346D2C1D1E080355B00424FC99290C7E5D729586504803A2D005E677F868C271AA479CEEB131592EE5450043A932697E6A92C6E164991EFC4268F25A294600B5002A3393B31CC834B972804D2F3A4FD72B928E59219C9C771EC3DC89D1802135C9806802729694A6E723FD6134C0129A019E600 -------------------------------------------------------------------------------- /years/2021/17/data.txt: -------------------------------------------------------------------------------- 1 | target area: x=175..227, y=-134..-79 -------------------------------------------------------------------------------- /years/2021/21/data.txt: -------------------------------------------------------------------------------- 1 | Player 1 starting position: 5 2 | Player 2 starting position: 6 -------------------------------------------------------------------------------- /years/2021/23/data.txt: -------------------------------------------------------------------------------- 1 | ############# 2 | #...........# 3 | ###C#B#A#D### 4 | #B#C#D#A# 5 | ######### -------------------------------------------------------------------------------- /years/2022/10/data.txt: -------------------------------------------------------------------------------- 1 | noop 2 | noop 3 | addx 5 4 | addx 3 5 | addx -2 6 | noop 7 | addx 5 8 | addx 4 9 | noop 10 | addx 3 11 | noop 12 | addx 2 13 | addx -17 14 | addx 18 15 | addx 3 16 | addx 1 17 | noop 18 | addx 5 19 | noop 20 | addx 1 21 | addx 2 22 | addx 5 23 | addx -40 24 | noop 25 | addx 5 26 | addx 2 27 | addx 3 28 | noop 29 | addx 2 30 | addx 3 31 | addx -2 32 | addx 2 33 | addx 2 34 | noop 35 | addx 3 36 | addx 5 37 | addx 2 38 | addx 3 39 | addx -2 40 | addx 2 41 | addx -24 42 | addx 31 43 | addx 2 44 | addx -33 45 | addx -6 46 | addx 5 47 | addx 2 48 | addx 3 49 | noop 50 | addx 2 51 | addx 3 52 | noop 53 | addx 2 54 | addx -1 55 | addx 6 56 | noop 57 | noop 58 | addx 1 59 | addx 4 60 | noop 61 | noop 62 | addx -15 63 | addx 20 64 | noop 65 | addx -23 66 | addx 27 67 | noop 68 | addx -35 69 | addx 1 70 | noop 71 | noop 72 | addx 5 73 | addx 11 74 | addx -10 75 | addx 4 76 | addx 1 77 | noop 78 | addx 2 79 | addx 2 80 | noop 81 | addx 3 82 | noop 83 | addx 3 84 | addx 2 85 | noop 86 | addx 3 87 | addx 2 88 | addx 11 89 | addx -4 90 | addx 2 91 | addx -38 92 | addx -1 93 | addx 2 94 | noop 95 | addx 3 96 | addx 5 97 | addx 2 98 | addx -7 99 | addx 8 100 | addx 2 101 | addx 2 102 | noop 103 | addx 3 104 | addx 5 105 | addx 2 106 | addx -25 107 | addx 26 108 | addx 2 109 | addx 8 110 | addx -1 111 | addx 2 112 | addx -2 113 | addx -37 114 | addx 5 115 | addx 3 116 | addx -1 117 | addx 5 118 | noop 119 | addx 22 120 | addx -21 121 | addx 2 122 | addx 5 123 | addx 2 124 | addx 13 125 | addx -12 126 | addx 4 127 | noop 128 | noop 129 | addx 5 130 | addx 1 131 | noop 132 | noop 133 | addx 2 134 | noop 135 | addx 3 136 | noop 137 | noop -------------------------------------------------------------------------------- /years/2022/11/data.txt: -------------------------------------------------------------------------------- 1 | Monkey 0: 2 | Starting items: 71, 56, 50, 73 3 | Operation: new = old * 11 4 | Test: divisible by 13 5 | If true: throw to monkey 1 6 | If false: throw to monkey 7 7 | 8 | Monkey 1: 9 | Starting items: 70, 89, 82 10 | Operation: new = old + 1 11 | Test: divisible by 7 12 | If true: throw to monkey 3 13 | If false: throw to monkey 6 14 | 15 | Monkey 2: 16 | Starting items: 52, 95 17 | Operation: new = old * old 18 | Test: divisible by 3 19 | If true: throw to monkey 5 20 | If false: throw to monkey 4 21 | 22 | Monkey 3: 23 | Starting items: 94, 64, 69, 87, 70 24 | Operation: new = old + 2 25 | Test: divisible by 19 26 | If true: throw to monkey 2 27 | If false: throw to monkey 6 28 | 29 | Monkey 4: 30 | Starting items: 98, 72, 98, 53, 97, 51 31 | Operation: new = old + 6 32 | Test: divisible by 5 33 | If true: throw to monkey 0 34 | If false: throw to monkey 5 35 | 36 | Monkey 5: 37 | Starting items: 79 38 | Operation: new = old + 7 39 | Test: divisible by 2 40 | If true: throw to monkey 7 41 | If false: throw to monkey 0 42 | 43 | Monkey 6: 44 | Starting items: 77, 55, 63, 93, 66, 90, 88, 71 45 | Operation: new = old * 7 46 | Test: divisible by 11 47 | If true: throw to monkey 2 48 | If false: throw to monkey 4 49 | 50 | Monkey 7: 51 | Starting items: 54, 97, 87, 70, 59, 82, 59 52 | Operation: new = old + 8 53 | Test: divisible by 17 54 | If true: throw to monkey 1 55 | If false: throw to monkey 3 -------------------------------------------------------------------------------- /years/2022/14/index.ts: -------------------------------------------------------------------------------- 1 | import _ from "lodash"; 2 | import * as util from "../../../util/util"; 3 | import * as test from "../../../util/test"; 4 | import chalk from "chalk"; 5 | import { log, logSolution, trace } from "../../../util/log"; 6 | import { performance } from "perf_hooks"; 7 | 8 | const YEAR = 2022; 9 | const DAY = 14; 10 | 11 | // solution path: C:\Users\trgau\dev\t-hugs\advent-of-code\years\2022\14\index.ts 12 | // data path : C:\Users\trgau\dev\t-hugs\advent-of-code\years\2022\14\data.txt 13 | // problem url : https://adventofcode.com/2022/day/14 14 | 15 | async function p2022day14_part1(input: string, ...params: any[]) { 16 | return "Not implemented"; 17 | } 18 | 19 | async function p2022day14_part2(input: string, ...params: any[]) { 20 | return "Not implemented"; 21 | } 22 | 23 | async function run() { 24 | const part1tests: TestCase[] = []; 25 | const part2tests: TestCase[] = []; 26 | 27 | // Run tests 28 | test.beginTests(); 29 | await test.section(async () => { 30 | for (const testCase of part1tests) { 31 | test.logTestResult(testCase, String(await p2022day14_part1(testCase.input, ...(testCase.extraArgs || [])))); 32 | } 33 | }); 34 | await test.section(async () => { 35 | for (const testCase of part2tests) { 36 | test.logTestResult(testCase, String(await p2022day14_part2(testCase.input, ...(testCase.extraArgs || [])))); 37 | } 38 | }); 39 | test.endTests(); 40 | 41 | // Get input and run program while measuring performance 42 | const input = await util.getInput(DAY, YEAR); 43 | 44 | const part1Before = performance.now(); 45 | const part1Solution = String(await p2022day14_part1(input)); 46 | const part1After = performance.now(); 47 | 48 | const part2Before = performance.now() 49 | const part2Solution = String(await p2022day14_part2(input)); 50 | const part2After = performance.now(); 51 | 52 | logSolution(14, 2022, part1Solution, part2Solution); 53 | 54 | log(chalk.gray("--- Performance ---")); 55 | log(chalk.gray(`Part 1: ${util.formatTime(part1After - part1Before)}`)); 56 | log(chalk.gray(`Part 2: ${util.formatTime(part2After - part2Before)}`)); 57 | log(); 58 | } 59 | 60 | run() 61 | .then(() => { 62 | process.exit(); 63 | }) 64 | .catch(error => { 65 | throw error; 66 | }); 67 | -------------------------------------------------------------------------------- /years/2023/06/data.txt: -------------------------------------------------------------------------------- 1 | Time: 38 67 76 73 2 | Distance: 234 1027 1157 1236 -------------------------------------------------------------------------------- /years/2023/20/data.txt: -------------------------------------------------------------------------------- 1 | &zq -> fd, gk, pp, ph, ss, dr, pl 2 | %qg -> jh, nk 3 | %lm -> lg, qm 4 | %fk -> lr 5 | %pp -> hh 6 | %bf -> sj, qm 7 | &qm -> kb, jl, bs, kx, bl, cz, dd 8 | %db -> dc, jn 9 | %kl -> dc, qv 10 | %xm -> jh 11 | %ss -> zq, nd 12 | %vq -> bh, dc 13 | %bl -> bs 14 | %fd -> gk 15 | &dc -> tx, vq, ct, df, fx 16 | %dj -> zq, pp 17 | %fv -> vj, zq 18 | %pv -> lm, qm 19 | %dg -> zz, jh 20 | %fc -> fk 21 | %qv -> dc, db 22 | &ls -> rx 23 | &tx -> ls 24 | %vl -> fc 25 | %dr -> fd 26 | &dd -> ls 27 | %kx -> jl 28 | %sj -> qm, bl 29 | %vj -> zq 30 | %nk -> jh, vl 31 | %xr -> kr, jh 32 | &nz -> ls 33 | %cz -> bf 34 | %ms -> qm 35 | %ct -> fx 36 | %lg -> qm, ms 37 | %lr -> dg 38 | %pl -> dr 39 | %rt -> zq, dj 40 | %jn -> dc 41 | %zz -> zm 42 | %kf -> kl, dc 43 | %jl -> cz 44 | %hh -> fv, zq 45 | %df -> mr 46 | &jh -> zz, lr, vl, fc, nz, fk, qg 47 | %fx -> hq 48 | %hq -> df, dc 49 | %kb -> qm, kx 50 | &ph -> ls 51 | broadcaster -> kb, vq, ss, qg 52 | %nd -> pl, zq 53 | %gk -> rt 54 | %mr -> dc, kf 55 | %bs -> pv 56 | %bh -> dc, ct 57 | %kr -> jh, xm 58 | %zm -> xr, jh -------------------------------------------------------------------------------- /years/2023/21/scratch.txt: -------------------------------------------------------------------------------- 1 | 1 = 1 2 | 3 | 1 = 4 4 | 1 1 5 | 1 6 | 7 | 1 = 9 8 | 1 1 9 | 1 1 10 | 1 1 11 | 1 12 | 13 | 14 | 1 = 16 15 | 1 1 16 | 1 1 17 | 1 1 18 | 1 1 19 | 1 1 20 | 1 21 | 22 | 1 = 25 23 | 1 1 24 | 1 1 25 | 1 1 26 | 1 1 27 | 1 1 28 | 1 1 29 | 1 1 30 | 1 -------------------------------------------------------------------------------- /years/2024/11/data.txt: -------------------------------------------------------------------------------- 1 | 9694820 93 54276 1304 314 664481 0 4 --------------------------------------------------------------------------------