You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A basic C# program for Advent of Code, retrieving puzzle inputs on the go and creating instances of solutions as they are created. It runs on .NET Core 3.1 and can be built easily in Visual Studio Code or Visual Studio.
3
-
4
-
## Requirements
5
-
* .NET Core 3.1
2
+
Template project for solving Advent of Code in C#, running on .NET Core 3.1.
-[Using a Solution's Constructor](#using-a-solutions-constructor)
13
+
-[Contributing](#contributing)
14
+
-[License](#license)
6
15
7
16
## Features
17
+
* Simple configuration with `config.json`.
8
18
* Fetches puzzle input from adventofcode.com and stores it locally.
9
-
* Dynamically outputs current date's puzzle solution, depending on configuration.
10
19
* Includes various useful utilities for typical puzzle problems.
11
-
* Simple configuration with config.json.
12
-
13
-
## Usage
14
-
### Create Project
15
-
Create a new project of your own from this template repository by clicking the button shown below, or through [this link](https://github.com/sindrekjr/AdventOfCodeBase/generate).
If you haven't already, use the button shown below (or [this link](https://github.com/sindrekjr/AdventOfCodeBase/generate)) to create a new repository of your own from this template.
20
23
21
-
### Cleanup
22
-
Make any file additions/modifications you want, such as removing solution files for previous years if you've no interest in completing those. You probably do not want to remove any files outside of `AdventOfCode/Solutions/` unless you know what you're doing.
23
-
24
-
### Generating Previous Year's Solution Files
25
-
Use the included PowerShell script `AdventOfCode/UserScripts/GenerateSolutionFiles.ps1` to generate a year's solution files following the same layout as those already included.
Feel free to make any modifications you want. However, you probably do not want to remove any files outside of `AdventOfCode/Solutions/` unless you know what you're doing.
28
27
29
-
If no value is provided it will generate files for the current year. The script will avoid overwriting existing files.
28
+
If any solutions files that you need are not already included, see **[Generating Previous Year's Solution Files](#generating-previous-years-solution-files)**.
30
29
31
-
Requires 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)
Create `config.json` with the following key/value pairs. If you run the program without adding a `config.json` file, one will be created for you without a cookie field. The program will not be able to fetch puzzle inputs from the web before a valid cookie is added to the configuration.
35
36
```json
36
37
{
@@ -39,23 +40,19 @@ Create `config.json` with the following key/value pairs. If you run the program
39
40
"days": [0]
40
41
}
41
42
```
42
-
#### `cookie`
43
-
Note that `c0nt3nt` must be replaced with a valid cookie value that your browser stores when logging in at adventofcode.com.
44
43
45
-
Instructions on locating your session cookie can be found here: https://github.com/wimglenn/advent-of-code-wim/issues/1
44
+
`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
46
45
47
-
#### `year`
48
-
Specifies which year you wish to output solutions for when running the project. If left unspecified will default to the current year.
46
+
`year` - Specifies which year you wish to output solutions for when running the project. If left unspecified will default to the current year.
49
47
50
-
#### `days`
51
-
Specifies which days you wish to output solutions for when running the project. The field supports list comprehension syntax and strings, meaning the following notations are valid.
48
+
`days` - Specifies which days you wish to output solutions for when running the project. The field supports list comprehension syntax and strings, meaning the following notations are valid.
52
49
*`"1..4, 10"` - runs day 1, 2, 3, 4, and 10.
53
50
*`[1, 3, "5..9", 15]` - runs day 1, 3, 5, 6, 7, 8, 9, and 15.
54
51
*`0` - runs all days
55
52
56
53
Will default to current day if left unspecified and an event is actively running. Otherwise will default to `0`
57
54
58
-
### Code
55
+
### Running the project
59
56
Write your code solutions to advent of code within the appropriate day classes in the Solutions folder, and run the project. From the command line you may do as follows.
60
57
```
61
58
> cd AdventOfCode
@@ -64,7 +61,17 @@ Write your code solutions to advent of code within the appropriate day classes i
64
61
```
65
62
Using `dotnet run` from the root of the repository will also work as long as you specify which project to run by adding `-p AdventOfCode`. Note that your `config.json` must be stored in the location from where you run your project.
66
63
67
-
#### Notes
64
+
## Notes & Examples
65
+
### Generating Previous Year's Solution Files
66
+
Use the included PowerShell script `AdventOfCode/UserScripts/GenerateSolutionFiles.ps1` to generate a year's solution files following the same layout as those already included.
67
+
68
+
Usage: `GenerateSolutionFiles.ps1 [-Year <Int>]`
69
+
70
+
If no value is provided it will generate files for the current year. The script will avoid overwriting existing files.
71
+
72
+
Requires 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)
73
+
74
+
### Using a Solution's Constructor
68
75
* Code may be written in the solution constructor if it will be beneficial to both parts of the problem (such as parsing the data). Example:
* The extension method `SplitByNewLine()` will do exactly that, example: `string[] lines = Input.SplitByNewLine()` will split your input into lines for enumeration.
94
101
95
102
## Contributing
96
-
Sure! Fork the project, make your changes, and submit a pull request.
103
+
Sure! Fork the project, make your changes, and create a pull request. Submitted issues and pull requests are quite welcome.
0 commit comments