advent_of_code_2024/Common/FulltextLevelSolverBase.cs

38 lines
1.0 KiB
C#

namespace AoC24.Common;
using AoCLevelInputProvider;
using Parsing;
using Parsing.Schema;
using Parsing.Tokenization;
public abstract class FullTextLevelSolverBase
{
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()
{
InputSchemaBuilder schemaBuilder = new InputSchemaBuilder();
var schema = this.DefineInputSchema(schemaBuilder).Build();
var parser = TextParser.Create(schema);
var data = parser
.SetInputText(this.GetLevelInput())
.Parse();
return data;
}
}