{"id":13778862,"url":"https://github.com/sindrekjr/AdventOfCodeBase","last_synced_at":"2025-05-11T12:32:05.386Z","repository":{"id":45254201,"uuid":"220677648","full_name":"sindrekjr/AdventOfCodeBase","owner":"sindrekjr","description":"Template repository for solving Advent of Code puzzles, which automatically handles input retrieval and output.","archived":false,"fork":false,"pushed_at":"2023-11-26T18:59:25.000Z","size":148,"stargazers_count":40,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-03T18:13:27.280Z","etag":null,"topics":["advent-of-code","csharp","netcore","puzzles","template"],"latest_commit_sha":null,"homepage":"","language":"C#","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/sindrekjr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-11-09T17:25:03.000Z","updated_at":"2024-02-17T19:28:36.000Z","dependencies_parsed_at":"2024-08-03T18:11:28.795Z","dependency_job_id":"17846655-7450-436b-bd24-f7146216cc7e","html_url":"https://github.com/sindrekjr/AdventOfCodeBase","commit_stats":null,"previous_names":[],"tags_count":3,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindrekjr%2FAdventOfCodeBase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindrekjr%2FAdventOfCodeBase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindrekjr%2FAdventOfCodeBase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindrekjr%2FAdventOfCodeBase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindrekjr","download_url":"https://codeload.github.com/sindrekjr/AdventOfCodeBase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225048997,"owners_count":17412907,"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-of-code","csharp","netcore","puzzles","template"],"created_at":"2024-08-03T18:00:58.288Z","updated_at":"2024-11-17T14:30:59.978Z","avatar_url":"https://github.com/sindrekjr.png","language":"C#","funding_links":[],"categories":["Project Templates"],"sub_categories":[],"readme":"# AdventOfCodeBase\nTemplate project for solving Advent of Code in C#, running on [.NET 8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0).\n\n- [Features](#features)\n- [Usage](#usage)\n  - [Creating a repository](#creating-a-repository)\n  - [Configuring](#configuring)\n  - [Running the project](#running-the-project)\n  - [Example solution](#example-solution)\n- [Notes](#notes)\n  - [Generating Solution Files](#generating-solution-files)\n  - [Automatic Debugger Break On Exception](#automatic-debugger-break-on-exception)\n- [Background](#background)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n* Simple configuration with `config.json`.\n* Fetches puzzle input from adventofcode.com and stores it locally.\n* Supports easily switching between debug-input and real input.\n* Naive benchmarking, showing as millisecond count.\n\n## Usage\n\n### Creating a repository\nTo get started using this template, click the green \"Use this template\" button above (or [this link](https://github.com/sindrekjr/AdventOfCodeBase/generate)) to create a new repository of your own from it.\n\nIf any solution files that you need are not already included, see **[Generating Previous Year's Solution Files](#generating-previous-years-solution-files)**.\n\n### Configuring\nCreate a new file named `config.json` at the root of the project.\n```json\n{\n  \"cookie\": \"c0nt3nt\",\n  \"year\": 2020,\n  \"days\": [0] \n}\n```\n\nIf you run the program without adding this file, one will be created for you without a cookie field. The program will not be able to fetch puzzle inputs from adventofcode.com before a valid cookie is added to the configuration. \n\n#### `cookie` - Note that `c0nt3nt` must be replaced with a valid cookie value that your browser stores when logging in at adventofcode.com. Instructions on locating your session cookie can be found here: https://github.com/wimglenn/advent-of-code-wim/issues/1\n\n#### `year` - Specifies which year you wish to output solutions for when running the project. Defaults to the current year if left unspecified.\n\n#### `days` - Specifies which days you wish to output solutions for when running the project. Defaults to current day if left unspecified and an event is actively running, otherwise defaults to `0`.\n\nThe field supports list comprehension syntax and strings, meaning the following notations are valid.\n* `\"1..4, 10\"` - runs day 1, 2, 3, 4, and 10.\n* `[1, 3, \"5..9\", 15]` - runs day 1, 3, 5, 6, 7, 8, 9, and 15.\n* `0` - runs all days\n\n### Running the project\nWrite your advent of code solutions in the appropriate solution classes, `AdventOfCode.Solutions/Year\u003cYYYY\u003e/Day\u003cDD\u003e/Solution.cs`.\n\nThen run the project. From the command line you can use `dotnet run`, and optionally specify a day inline. For example, to run your solution for day 21:\n```\ndotnet run 21\n```\n\n### Example solution\n```csharp\nclass Solution : SolutionBase\n{\n    // the constructor calls its base class with (day, year, name)\n    public Solution() : base(02, 2021, \"The Big Bad Sample Santa\")\n    {\n        // you can use the constructor for preparations shared by both part one and two if you wish\n    }\n    \n    protected override string SolvePartOne()\n    {\n        var lines = Input.SplitByNewline();\n        return lines.First();\n        // this would return the first line of the input as this part's solution\n    }\n    \n    protected override string SolvePartTwo()\n    {\n        Debug = true;\n        // we choose to use the debug input for this part\n        // note that the debug input cannot be fetched automatically; it has to be copied into the solution folder manually\n        return \"\";\n    }\n}\n```\n\n## Notes\n### Generating Solution Files\n\nSolution files can be automatically generated via GNU Make or PowerShell, and both methods use the included file `solution.template`, which is customisable. Both options default to current YEAR and all DAYS (1-25).\n\n#### GNU Make\n\n```bash\n$ make solution-files [,YEAR] [,DAYS]\n```\n\nRequires GNU Make v4 or later.\n\n#### PowerShell\n\n```pwsh\n\u003e GenerateSolutionFiles.ps1 [-Year \u003cInt\u003e]\n```\n\nRequires PowerShell v3 or later due to the way `$PSScriptRoot` behaves. If you have Windows 8+ you should be set. Upgrades for previous versions, and installs for macOS and Linux can be found in [Microsoft's Powershell Documentation](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.1)\n\n### Automatic Debugger Break On Exception\nWhen running your Solutions with a Debugger attached e.g. [VSCode](https://code.visualstudio.com/docs/editor/debugging) or [Visual Studio](https://docs.microsoft.com/en-us/visualstudio/debugger/quickstart-debug-with-managed?view=vs-2019) the BaseSolution base class will try to pause/break the debugger when there is an uncaught Exception thrown by your solution part. This allows for inspection with the debugger without having to specifically set-up additional exception handling within the debugger or your solution.\n\n## Background\nI intended to use Advent of Code 2019 to learn C#, and found that I wanted to try to put together a small solutions framework of my own. In that way this template came about as an introductory project to C# and .NET Core.\n\n## Contributing \nIf you wish to contribute to this project, simply fork and the clone the repository, make your changes, and submit a pull request. Contributions are quite welcome!\n\nPlease adhere to the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/).\n\n## License\n[MIT](https://github.com/sindrekjr/AdventOfCodeBase/blob/master/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindrekjr%2FAdventOfCodeBase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindrekjr%2FAdventOfCodeBase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindrekjr%2FAdventOfCodeBase/lists"}