Skip to content

Commit 5ff5a6f

Browse files
authored
Update README.md
1 parent f6a1ef3 commit 5ff5a6f

File tree

1 file changed

+89
-53
lines changed

1 file changed

+89
-53
lines changed

README.md

Lines changed: 89 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88

99
## Advantages
1010

11-
In order to solve your puzzle, you might need the debugger from time to time,
12-
especially as the puzzles become harder.
11+
In order to solve your puzzle, you might need the debugger from time to time, especially as the puzzles become harder.
1312

14-
This template is built around test projects, in order to take advatage of the
15-
debugging possibilities and TDD if you want to.
13+
This template is built around test projects, in order to take advatage of the debugging possibilities and TDD if you want to.
14+
15+
Here are also a bunch of features offered by the template:
16+
17+
- Retrieval of the puzzle input localy or remotely
18+
- Testing of the puzzle examples
19+
- Conditionnaly skip the tests of a puzzle if wanted
1620

1721
## Usage
1822

@@ -35,27 +39,41 @@ You will then have to implement three different logics:
3539
2. **The logic for the first part of the puzzle**
3640
3. **The logic for the second part of the puzzle**
3741

38-
> For example, if the first part of the puzzle is "Given a list of integers, find the greatest one" and the second one
39-
> "Now find the sum of them", we can do the following:
40-
>
41-
> ```csharp
42-
> public class Solver : Solver<int[], int>
43-
> {
44-
> protected override string InputPath => "input.txt";
45-
>
46-
> public override int PartOne(int[] input)
47-
> => input.Max();
48-
>
49-
> public override int PartTwo(int[] input)
50-
> => input.Sum();
51-
>
52-
> public override int[] ReadInput(string inputPath)
53-
> => File
54-
> .ReadAllLines(inputPath)
55-
> .Select(int.Parse)
56-
> .ToArray();
57-
> }
58-
> ```
42+
For example, if the first part of the puzzle is "Given a list of integers, find the greatest one" and the second one "Now find the sum of them", we can do the following:
43+
44+
```csharp
45+
public class Solver : Solver<int[], int>
46+
{
47+
public Solver() : base(inputPath: "WithLocalInput/input.txt") { }
48+
49+
public override int PartOne(int[] input)
50+
=> input.Max();
51+
52+
public override int PartTwo(int[] input)
53+
=> input.Sum();
54+
55+
public override int[] ParseInput(IEnumerable<string> input)
56+
=> input.Select(int.Parse).ToArray();
57+
}
58+
```
59+
60+
If you prefer fetching your input from the server, you can instead specify the date:
61+
62+
```csharp
63+
public class Solver : Solver<int[], int>
64+
{
65+
public Solver() : base(year: 0000, day: 00) { }
66+
67+
public override int PartOne(int[] input)
68+
=> input.Max();
69+
70+
public override int PartTwo(int[] input)
71+
=> input.Sum();
72+
73+
public override int[] ParseInput(IEnumerable<string> input)
74+
=> input.Select(int.Parse).ToArray();
75+
}
76+
```
5977

6078
### Testing your solution
6179

@@ -70,37 +88,55 @@ Those represent the input of each part of the puzzle of the day.
7088
For each part you will have to specify what the example is (its input and solution) and the solution you are expecting.
7189
Specifying the example allows the engine to test your solution against a predictible result in order to help you to debug it.
7290

73-
> Keeping our example in mind, the associated `TestEngine` might be:
74-
>
75-
> ```csharp
76-
> public class SolverTest : TestEngine<Solver, int[], int>
77-
> {
78-
> public override Puzzle PartOne => new()
79-
> {
80-
> Example = new()
81-
> {
82-
> Input = new[] { 1, 2, 3 },
83-
> Result = 3,
84-
> },
85-
>
86-
> Solution = 5,
87-
> };
88-
>
89-
> public override Puzzle PartTwo => new()
90-
> {
91-
> Example = new()
92-
> {
93-
> Input = new[] { 1, 2, 3 },
94-
> Result = 6,
95-
> },
96-
>
97-
> Solution = 15,
98-
> };
99-
> }
100-
> ```
91+
Keeping our example in mind, the associated `TestEngine` might be:
92+
93+
```csharp
94+
public class SolverTest : TestEngine<Solver, int[], int>
95+
{
96+
public override Puzzle PartOne => new()
97+
{
98+
ShouldSkipTests = false, // Default to false
99+
Example = new()
100+
{
101+
Input = new[] { 1, 2, 3 },
102+
Result = 3,
103+
},
104+
Solution = 5,
105+
};
106+
107+
public override Puzzle PartTwo => new()
108+
{
109+
Example = new()
110+
{
111+
Input = new[] { 1, 2, 3 },
112+
Result = 6,
113+
},
114+
Solution = 15,
115+
};
116+
}
117+
```
101118

102119
## Troubleshooting
103120

121+
### How can I find my cookie?
122+
123+
Under the website of the [Advent of Code](https://adventofcode.com), open the dev tools and find the Advent of Code cookie in your storage:
124+
125+
![Example](https://user-images.githubusercontent.com/22640284/205501479-31e2e5ef-d50e-43f8-8a45-4741a473861c.png)
126+
127+
You can then copy its value.
128+
129+
### Where can I set my cookie?
130+
131+
You can either provide the cookie as an environment variable named `AOC_COOKIE`, or directly set it in the `Configuration.cs` file:
132+
133+
```csharp
134+
public static class Configuration
135+
{
136+
public readonly static string? CookieValue = "YOUR-COOKIE-HERE";
137+
}
138+
```
139+
104140
### My input is missing!
105141

106142
Be sure to have your input data accessible, you can do so by indicating how VS should take care of your file:

0 commit comments

Comments
 (0)