eduherminio / aochelper Goto Github PK
View Code? Open in Web Editor NEWHelper .NET library for solving Advent of Code puzzles
Home Page: https://adventofcode.com
License: MIT License
Helper .NET library for solving Advent of Code puzzles
Home Page: https://adventofcode.com
License: MIT License
I think it might be useful to (optionally?) allow to capture the timings of the day constructors. Day 7 of 2020, had a lot of up front processing that both parts leveraged. instead of doing it twice, it makes sense to put in the constructor. However doing so, the Part 1 and Part 2 become a lot slimmer just leveraging the data structures built by the constructor, and I think this results in artificially low runtimes, since the bulk of the processing wasn't accounted for.
Hi :-)
When I run my project using SolveAll in Debug mide, all is well and I get a nice pribntout of the 7 days so far.
Using release more, however, trips at day 3:
I think this happens when my code throws an exception and then the exception message and stack trace contain brackets []
the console format thing assumes special meaning so I suppose you need to escape those brackets before sending them into the console.
Regardless if I pass true or false for ClearConsole, it clears anyways. Looking at the code here, it seems it will do a clear no matter what, just either a Console.Clear or an AnsiConsole Clear.
I'd like to be able to use Console.WriteLine (or AnsiConsole.WriteLine) for debugging and not have those lines wiped out by the results.
Using Solver.SolveAll();
will result in a reverse order, and somehow a duplicate being printed, as seen below:
This is my folder structure:
It looks like this issue is related to #137, but I'm not sure why this happens in my case.
For some reason, the Part 1 for everything is taking much longer than part 2 of the same question. For example:
I am not sure why this is the case. For Day 1, part 1 is doing significantly less than part 2. For Day 2, both parts are the exact same. Could this be related to how I have written my parts or is this something related to when AoCHelper starts the timer? This may also be a case of me not entirely understanding how the Helper is supposed to work.
Please note, I am using the Template that is linked in the main Readme.
Here is an example of how my Day 2 is set up:
public class Day_02 : BaseDay
{
private readonly string _input;
public Day_02()
{
_input = File.ReadAllText(InputFilePath);
}
public override ValueTask<string> Solve_1() => Part1();
public override ValueTask<string> Solve_2() => Part2();
private ValueTask<string> Part1()
{
throw new System.NotImplementedException();
}
private ValueTask<string> Part2()
{
throw new System.NotImplementedException();
}
}
Some exceptions cannot be parsed by Spectre.Console
, which then throws an System.InvalidOperationException
that remains unhandled.
In MelvinSnijders/AdventOfCode2022 (more specifically in this commit) the table seems to be rendered twice.
User screenshot (from #140):
Would be nice if I could dependency inject the solver.
What you've done in your pull.ps1 I have done in C# by injecting a http client.
Add an option to solve a problem my index.
Example:
Solver.Solve(12)
should solve problem(s) where CalculateIndex()
returns 12.
This should facilitate the parsing of arguments from standard input (idea taken from here, thanks @ZeevoX!).
Once the functionality is implemented, it'd be nice to provide something out of the box in the template.
Just installed AocHelper and using the Template. When attempting to debug my code, the SolveLast method throws an IOException when attempting to set the cursor visibility.
This project has run successfully when not using the debugger.
This same code, when debugged using Visual Studio, will run just fine (debugger behaves without throwing the exception).
I suspect this is some configuration or installation problem on my end with VSCode. Have you seen anything like this before?
Would be nice if we could set a config property that would run each solution N number of times and take the average timing across those runs. Where N is the value set in config.
SolverConfiguration cfg = new();
cfg.RunCount = 20;
Solver.SolveAll(cfg);
Hi,
Thanks for this great tool ! I am using it again this year.
I have a mix between a feature request / question :
I'd like to implement some tests, but not using my own input files, but the small examples that is provided for each question (let's call them demo inputs).
As of now, I have to switch the inputs, but it is very redundant between each part and all my typos ^^'.
I suppose writing a Tests folder that take "test" inputs would be the best, but that mean I need to override by hand each BaseDay
just to override InputFileDirPath
so that it is the demo input that is used for testing.
Do you think that could be an added feature, or do you see a better way to do it ?
For SolveAll() it might be nice to see a sum of all problem run times printed out at the end.
I was wondering if it might be possible to have either additional assemblies, or at least one alternative assembly for Solver
to solve problems from. I have a project structure for showing solutions in both a console app and a web app, and I'd like to be able to reference a library containing the problems / solutions.
I added a Day02.cs today, and tried SolveLast() but it ran Day01 again. Running Solver.SolveAll() results in this output:
As far as I can tell the SolveAll() relies on LoadAllProblems() which just scans the assembly for classes that extend BaseDay but doesn't sort them? Unsure how to resolve this on my side, hoping you have some ideas (or I'm doing something wrong).
I've taken the idea of your framework and expanded on it by allowing for multiple years.
My updated project structure is as follows:
+---AdventOfCode
| AdventOfCode.csproj
| GlobalUsings.cs
| Program.cs
|
+---2015
| | Day_01.cs
| | Day_02.cs
| | Day_03.cs
| |
| \---Inputs
| 01.txt
| 02.txt
| 03.txt
|
+---2021
| Day_01.cs
| Day_02.cs
| Day_03.cs
|
\---Inputs
01.txt
02.txt
03.txt
It would be nice to get better performance!
SolverConfiguration.ClearConsole
doesn't work properly.
More specifically, it doesn't work at least when the output to clear is big (i.e. you've solved a bunch of days or are using SolverConfiguration.ShowConstructorElapsedTime
or/and SolverConfiguration.ShowTotalElapsedTimePerDay
), but sometimes in other scenarios as well.
It doesn't matter what combination of Console.Clear()
and/or AnsiConsole.Console.Clear(true)
is used, but I can't find a way to fully clear the output of previous runs.
Back buffer rendering technique mentioned in spectreconsole/spectre.console#156 to re-render the table doesn't fix this issue either.
Bump spectre.console to v0.40.0 and take advantage of spectreconsole/spectre.console#156 (comment).
If that can be successfully adopted, it'd solve #43 as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.