35 lines
1023 B
C#
35 lines
1023 B
C#
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();
|
|
}
|
|
}
|
|
}
|
|
} |