Initial Commit
This commit is contained in:
35
2023/AdventCommon/PuzzleInput.cs
Normal file
35
2023/AdventCommon/PuzzleInput.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace AdventCommon
|
||||
{
|
||||
public class PuzzleInput
|
||||
{
|
||||
public PuzzleInput(string fileName, bool ignoreEmptyLines = true)
|
||||
{
|
||||
using (StreamReader reader = System.IO.File.OpenText(fileName))
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string? line = reader.ReadLine();
|
||||
|
||||
if (line == null) { throw new InvalidDataException(); }
|
||||
if (ignoreEmptyLines && String.IsNullOrWhiteSpace(line)) continue;
|
||||
|
||||
Lines.Add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> Lines { get; private set; } = new List<string>();
|
||||
|
||||
public void Print()
|
||||
{
|
||||
for (int j = 0; j < Lines.Count; j++)
|
||||
{
|
||||
for (int i = 0; i < Lines[j].Length; i++)
|
||||
{
|
||||
Console.Write(Lines[j][i]);
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user