refactor: Change Input loading to class instead of reader
This commit is contained in:
parent
1a4e35b61c
commit
3723115a4a
7 changed files with 53 additions and 38 deletions
16
AdventOfCode2025/Inputs/Input.cs
Normal file
16
AdventOfCode2025/Inputs/Input.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
namespace AdventOfCode2025.Inputs;
|
||||
|
||||
public sealed record Input(int Day, int PartNumber = 1)
|
||||
{
|
||||
private const string BasePath = "../../../Inputs/";
|
||||
public string ToPath() => BasePath + $"Day{Day}_{PartNumber}.txt";
|
||||
}
|
||||
|
||||
public static class InputExtensions
|
||||
{
|
||||
extension(Input input)
|
||||
{
|
||||
public IEnumerable<string> Lines => File.ReadAllLines(input.ToPath());
|
||||
public IEnumerable<T> GetLines<T>(Func<string, T> parser) => input.Lines.Select(parser);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue