Initial Commit
This commit is contained in:
31
2024/AdventCommon/ParsedInput.cs
Normal file
31
2024/AdventCommon/ParsedInput.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AdventCommon
|
||||
{
|
||||
public abstract class ParsedInput
|
||||
{
|
||||
public virtual object? GetContext() { return null; }
|
||||
|
||||
public abstract bool ParseLine(string line, object? context = null);
|
||||
|
||||
public virtual long GetPart01() { return 0; }
|
||||
public virtual long GetPart02() { return 0; }
|
||||
|
||||
public ParsedInput(string fileName)
|
||||
{
|
||||
var input = new AdventCommon.PuzzleInput(fileName);
|
||||
|
||||
foreach (var line in input.Lines)
|
||||
{
|
||||
if (!ParseLine(line, GetContext()))
|
||||
{
|
||||
throw new Exception("Line not formatted as expected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user