32 lines
843 B
C#
32 lines
843 B
C#
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");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|