{"id":16974771,"url":"https://github.com/nulldev/advent-of-code","last_synced_at":"2025-04-12T00:31:58.917Z","repository":{"id":40310486,"uuid":"317839172","full_name":"NullDev/Advent-of-Code","owner":"NullDev","description":":christmas_tree: My solutions for the Advent of Code in NodeJS","archived":false,"fork":false,"pushed_at":"2024-12-25T16:55:26.000Z","size":1646,"stargazers_count":13,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T13:45:40.541Z","etag":null,"topics":["advent","advent-of-code","advent-of-code-2019","advent-of-code-2020","advent-of-code-2021","advent-of-code-2022","advent-of-code-2023","adventofcode","javascript","js","nodejs","nulldev","solutions"],"latest_commit_sha":null,"homepage":"https://adventofcode.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NullDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-02T11:22:37.000Z","updated_at":"2025-03-19T01:04:14.000Z","dependencies_parsed_at":"2024-12-03T06:18:00.260Z","dependency_job_id":"3201c46a-f975-4e84-b7de-fad86ef69074","html_url":"https://github.com/NullDev/Advent-of-Code","commit_stats":{"total_commits":431,"total_committers":5,"mean_commits":86.2,"dds":0.4245939675174014,"last_synced_commit":"12226228eefd0ce37c61cc1e285c2a19f4b96af2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullDev%2FAdvent-of-Code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullDev%2FAdvent-of-Code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullDev%2FAdvent-of-Code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullDev%2FAdvent-of-Code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NullDev","download_url":"https://codeload.github.com/NullDev/Advent-of-Code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501402,"owners_count":21114672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advent","advent-of-code","advent-of-code-2019","advent-of-code-2020","advent-of-code-2021","advent-of-code-2022","advent-of-code-2023","adventofcode","javascript","js","nodejs","nulldev","solutions"],"created_at":"2024-10-14T01:08:00.447Z","updated_at":"2025-04-12T00:31:58.891Z","avatar_url":"https://github.com/NullDev.png","language":"JavaScript","readme":"# :christmas_tree: Advent-of-Code\n\n\u003cp align=\"center\"\u003e\u003cimg height=\"250\" width=\"auto\" src=\"https://i.imgur.com/1zABhbB.png\" /\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003cb\u003eMy solutions for the Advent of Code in NodeJS\u003c/b\u003e\u003c/p\u003e\n\u003chr\u003e\n\n## :information_source: About Advent of Code\n\nEach day consists of two puzzles. \u003cbr\u003e\nI added a README.md file to each Day, which contains the instructions exactly as they were displayed on https://adventofcode.com/\n\n\u003chr\u003e\n\n## :bulb: How to use this repository\n\n### :wrench: Initial Setup\n\n0. Open up your favourite terminal (and navigate somewhere you want to download the repository to). \u003cbr\u003e\u003cbr\u003e\n1. Make sure you have NodeJS installed. Test by entering \u003cbr\u003e\n$ `node -v` \u003cbr\u003e\nIf this returns a version number, NodeJS is installed. **If not**, get NodeJS \u003ca href=\"https://nodejs.org/en/download/package-manager/\"\u003ehere\u003c/a\u003e. \u003cbr\u003e\u003cbr\u003e\n2. Clone the repository and navigate to it.\u003cbr\u003e\n$ `git clone https://github.com/NullDev/Advent-of-Code.git \u0026\u0026 cd Advent-of-Code` \u003cbr\u003e\u003cbr\u003e\n3. Install all dependencies by typing \u003cbr\u003e\n$ `npm install`\u003cbr\u003e\u003cbr\u003e\n4. Remove all years that weren't made by you (if all: `rm -r \"./20*\"`) and maybe alter the README\u003cbr\u003e\u003cbr\u003e\n5. Copy `config.template.json` and paste it as `config.json`\u003cbr\u003e\u003cbr\u003e\n6. Go to https://adventofcode.com/ and login with your account. Then copy the value from the `session` cookie and paste it into the `config.json` file (See [here](https://www.cookieyes.com/blog/how-to-check-cookies-on-your-website-manually/) if you don't know how).\u003cbr\u003e\u003cbr\u003e\n7. (OPTIONAL) If you wish to use the GitHub Action for the \"Prepare Day automatically at 0:10 workflow\" you need to go to your repository settings -\u003e secrets -\u003e actions and add `SESSION_COOKIE` with your session string. \u003cbr\u003e\u003cbr\u003e\n\n### :sunny: Starting a new day\n\n- To automatically setup and prepare the current day, simply type `npm run prepare-today`\n  - If you finished part one and want to get the readme updated, simple run the command again.\n- Optionally, to prepare a previous day, type `node prepare_day.js YEAR-DAY`- Example: `node prepare_day.js 2020-12`\n\nBoth of those commands will create a folder for the day/year, fetch the task from the website \u0026 convert it to a README.md, fetch the input and create template files for the solution.\n\n### :rocket: Running benchmarks \n\nEach script can be run stand-alone / separatly but I've also created a `start_all.js` script to launch all days in order, and display the solutions along with an approximated benchmark (the benchmark uses [`performance.now()`](https://nodejs.org/api/perf_hooks.html#perf_hooks_performance_now) to measure the execution time and **does not include the actual reading of the file** except when the file is read line-by-line).\n\n- Run all years: `npm run start:all`\n- Run a specific year: `npm run start:YEAR`- Example: `npm run start:2020`\n- Run a specific year and day: `npm run start:YEAR DAY`- Example: `npm run start:2020 3`\n- Run todays parts: `npm run start:today`\n- Run a specific day \u0026 part: `node YEAR/DAY/part_[1 OR 2].js`- Example: `node 2020/01/part_2.js`\n\n\u003chr\u003e\n\n## :scroll: License\n\n- All Puzzles \u0026 Inputs (`Day_XX/README.md`'s and `Day_XX/input.txt`'s) Copyright (c) Eric Wastl ([@ericwastl](https://twitter.com/ericwastl))\n- All Puzzle Solutions[^1] (`Day_XX/part_1.js`'s and `Day_XX/part_2.js`'s) Copyright (c) NullDev ([nulldev.org](https://nulldev.org))\n\n[^1]: Unless otherwise noted in the Code\n\n\u003chr\u003e\n\n## :trophy: Goal\n\nI attempted to solve every problem as functional as possible and with as little code as possible while still being performant. \u003cbr\u003e\nSome solutions could be one-liners¹ but I left them splitted up for the sake of readability. \n\n\u003csub\u003e¹: One-Liner as in one semantical instruction (e.g. chained higher order functions. putting semicolons in one line does not count)\u003c/sub\u003e\n\nI also tried to experiment with a couple of different things:\n\n**2019**: \u003ca name=\"best-2019\"\u003e\u003c/a\u003e\n\n- Single-Liner in [Day_01/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2019/Day_01/part_1.js)\n- Single-Liner on Day 04 in both [part_1](https://github.com/NullDev/Advent-of-Code/blob/master/2019/Day_04/part_1.js) and [part_2](https://github.com/NullDev/Advent-of-Code/blob/master/2019/Day_04/part_2.js)\n\n**2020**: \u003ca name=\"best-2020\"\u003e\u003c/a\u003e\n\n- Solution with logical XOR-ing in [Day_02/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_02/part_2.js)\n- Theoretical single-liner (single chain function) in [Day_04/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_04/part_1.js)\n- Completely branchless approach in [Day_04/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_04/part_2.js)\n- Another theoretical single-liner in [Day_06/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_06/part_1.js) and [Day_06/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_06/part_2.js)\n- Recursive curried function in [Day_07/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_07/part_1.js)\n- Another theoretical one-liner in [Day_10/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_10/part_1.js)\n- More branchless solutions in [Day_12/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_12/part_1.js) and [Day_12/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_12/part_2.js)\n- Yet another single-liner in [Day_13/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_13/part_1.js)\n- Experiment with bit-shift, bitwise operations and bigint numbers in [Day_14/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_14/part_2.js)\n- Another theoretical one-liner in [Day_16/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_16/part_1.js)\n- Recursive [IIFE](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) arrow function to minimize code in [Day_17/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_17/part_1.js)\n- Theoretical one-liner by utilizing the [Lambda calculus Y-combinator](https://en.wikipedia.org/wiki/Fixed-point_combinator#Fixed-point_combinators_in_lambda_calculus) with an [recursive anonymous arrow function](http://kestas.kuliukas.com/YCombinatorExplained/) in [Day_18/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_18/part_1.js)\n- Theoretical (_almost_) one-liner in [Day_20/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_20/part_1.js)\n- The final one-liner in [Day_25/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2020/Day_25/part_1.js)\n\n**2021**: \u003ca name=\"best-2021\"\u003e\u003c/a\u003e\n\n- Single-Liner on Day 01 in both [part_1](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_01/part_1.js) and [part_2](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_01/part_2.js)\n- Solution in `O(n)` on Day 06 in both [part_1](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_06/part_1.js) and [part_2](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_06/part_2.js) (See the [Note](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_06/part_1.js#L16-L33))\n- Single-Liner on Day 07 in both [part_1](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_07/part_1.js) and [part_2](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_07/part_2.js) by using a [formula transformation](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_07/part_2.js#L18-L21)\n- Single-Liner in [Day_08/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_08/part_1.js)\n- Another Single-Liner in [Day_09/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_09/part_1.js)\n- Theoretical (almost) Single-Liner in [Day_10/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_10/part_2.js)\n- Single-Liner in [Day_13/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_13/part_1.js)\n- Single-Liner in [Day_17/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_17/part_1.js)\n- Singe-Liner in [Day_21/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_21/part_1.js)\n- Recursive IIFE in [Day_21/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_21/part_2.js)\n- Single-Liners \u0026 IIFE's on Day 22 in both [part_1](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_22/part_1.js) and [part_2](https://github.com/NullDev/Advent-of-Code/blob/master/2021/Day_22/part_2.js)\n\n**2022** \u003ca name=\"best-2022\"\u003e\u003c/a\u003e\n\n- Pretty straight forward one-liners in both [Day_01/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2022/Day_01/part_1.js) and [Day_01/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2022/Day_01/part_2.js)\n- Another one-liner in both [Day_04/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2022/Day_04/part_1.js) and [Day_04/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2022/Day_04/part_2.js)\n- Yet another one-line solution in both [Day_06/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2022/Day_06/part_1.js) and [Day_06/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2022/Day_06/part_2.js)\n\n**2023** \u003ca name=\"best-2023\"\u003e\u003c/a\u003e\n\n- One-Liner in [Day_01/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_01/part_1.js)\n- One-Liner in both [Day_02/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_02/part_1.js) and [Day_02/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_02/part_2.js)\n- One-Liner in both [Day_04/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_04/part_1.js) and [Day_04/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_04/part_2.js)\n- One-Liner in [Day_06/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_06/part_1.js)\n- One-Liner in both [Day_11/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_11/part_1.js) and [Day_11/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_11/part_2.js)\n- One-Liner in both [Day_12/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_12/part_1.js) and [Day_12/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_12/part_2.js)\n- One-Liner in both [Day_13/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_13/part_1.js) and [Day_13/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_13/part_2.js) - both using Binary Matrices\n- One-Liner in [Day_14/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_14/part_1.js)\n- One-Liner in both [Day_15/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_15/part_1.js) and [Day_15/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_15/part_2.js)\n- One-Liner in [Day_24/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2023/Day_24/part_1.js)\n\n**2024** \u003ca name=\"best-2024\"\u003e\u003c/a\u003e\n\n- One-Liner in both [Day_02/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_02/part_1.js) and [Day_02/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_02/part_2.js)\n- One-Liner in both [Day_03/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_03/part_1.js) and [Day_03/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_03/part_2.js)\n- One-Liner in both [Day_04/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_04/part_1.js) and [Day_04/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_04/part_2.js)\n- One-Liner in [Day_05/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_05/part_1.js)\n- Dependency Graph with topological sorting _almost_ One-Liner in [Day_05/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_05/part_2.js)\n- One-Liner in [Day_06/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_06/part_1.js)\n- One-Liner in [Day_07/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_07/part_1.js)\n- [DFS](https://en.wikipedia.org/wiki/Depth-first_search) with Memoization in [Day_07/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_07/part_2.js)\n- One-Liner in both [Day_08/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_08/part_1.js) and [Day_08/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_08/part_2.js)\n- _Almost_ One-Liner [DFS](https://en.wikipedia.org/wiki/Depth-first_search) in both [Day_10/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_10/part_1.js) and [Day_10/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_10/part_2.js)\n- Recursive memoized _almost_ One-Liner in [Day_11/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_11/part_1.js) and [Day_11/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_11/part_2.js)\n- One-Liner in both [Day_13/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_13/part_1.js) and [Day_13/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_13/part_2.js)\n- One-Liner in [Day_14/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_14/part_1.js)\n- Sloppy, hacky, small, quick \u0026 dirty dijkstra in [Day_16/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_16/part_1.js)\n- _Almost_ One-Liner [BFS](https://en.wikipedia.org/wiki/Breadth-first_search) in [Day_18/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_18/part_1.js)\n- [DP](https://en.wikipedia.org/wiki/Dynamic_programming) One-Liner with memoization in both [Day_19/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_19/part_1.js) and [Day_19/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_19/part_2.js)\n- One-Liner in [Day_23/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_23/part_1.js)\n- Single-Line [Bron–Kerbosch algorithm](https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm) in [Day_23/part_2.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_23/part_2.js)\n- Final One-Liner in [Day_25/part_1.js](https://github.com/NullDev/Advent-of-Code/blob/master/2024/Day_25/part_1.js)\n\n\u003chr\u003e\n\n## :rocket: Benchmarks Preview\n\n\u003cp align=\"center\"\u003e\u003cimg height=\"auto\" width=\"100%\" src=\"https://i.imgur.com/Z5ci7OS.png\" /\u003e\u003c/p\u003e\n\n\u003chr\u003e\n\n## :star: Yay\n\n![image](https://user-images.githubusercontent.com/22935000/147389049-3b1c9830-28d8-45e5-968c-7375f133accc.png)\n\n\u003chr\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnulldev%2Fadvent-of-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnulldev%2Fadvent-of-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnulldev%2Fadvent-of-code/lists"}