advent_of_code_2024/Common/LevelSolverBase.cs
2024-12-02 18:51:49 +01:00

38 lines
998 B
C#

namespace AoC24.Common;
using AoCLevelInputProvider;
using Parsing;
using Parsing.Schema;
using Parsing.Tokenization;
public abstract class LevelSolverBase
{
public abstract int LevelNumber { get; }
private int Year = 2024;
private LevelInputProvider inputProvider = new LevelInputProvider();
protected string GetLevelInput()
{
return inputProvider.WithYear(this.Year).WithLevel(this.LevelNumber).Provide();
}
public abstract string SolveFirstStar();
public abstract string SolveSecondStar();
protected abstract InputSchemaBuilder DefineInputSchema(InputSchemaBuilder schemaBuilder);
public TokenConverter GetData()
{
var schemaBuilder = new InputSchemaBuilder();
var schema = this.DefineInputSchema(schemaBuilder).Build();
var parser = new TextParser(schema);
var data = parser
.SetInputText(this.GetLevelInput())
.Parse();
return data;
}
}