advent_of_code_2024/Common/FulltextLevelSolverBase.cs

39 lines
1.0 KiB
C#
Raw Permalink Normal View History

2024-12-02 18:51:49 +01:00
namespace AoC24.Common;
using AoCLevelInputProvider;
using Parsing;
using Parsing.Schema;
2024-12-13 16:04:54 +01:00
using Parsing.Data;
2024-12-02 18:51:49 +01:00
using Parsing.Tokenization;
public abstract class FullTextLevelSolverBase
2024-12-02 18:51:49 +01:00
{
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();
2024-12-02 18:51:49 +01:00
var schema = this.DefineInputSchema(schemaBuilder).Build();
var parser = TextParser.Create(schema);
2024-12-02 18:51:49 +01:00
var data = parser
.SetInputText(this.GetLevelInput())
.Parse();
return data;
}
}