Create AdventOfCode.Common.
This commit is contained in:
@@ -11,4 +11,8 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AdventOfCode.Common\AdventOfCode.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace AdventOfCode2020;
|
||||
|
||||
public interface IDay
|
||||
{
|
||||
string ResolvePart1(string[] inputs);
|
||||
string ResolvePart2(string[] inputs);
|
||||
}
|
||||
@@ -1,65 +1,3 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
global using AdventOfCode.Common;
|
||||
|
||||
namespace AdventOfCode2020;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
int currentDayNumber = 0;
|
||||
|
||||
DateTime date = DateTime.UtcNow.AddHours(-5);
|
||||
if (date.Month == 12 && currentDayNumber == 0)
|
||||
{
|
||||
currentDayNumber = date.Day;
|
||||
}
|
||||
|
||||
RunDay(currentDayNumber);
|
||||
|
||||
Console.Read();
|
||||
}
|
||||
|
||||
public static void RunDay(int currentDayNumber)
|
||||
{
|
||||
Console.WriteLine($"Day {currentDayNumber:00}");
|
||||
Console.WriteLine("------");
|
||||
Console.WriteLine();
|
||||
|
||||
IDay currentDay = null;
|
||||
Type dayType = Type.GetType($"AdventOfCode2020.Day{currentDayNumber:00}");
|
||||
if (dayType != null)
|
||||
{
|
||||
currentDay = Activator.CreateInstance(dayType) as IDay;
|
||||
}
|
||||
if (currentDay == null)
|
||||
{
|
||||
Console.WriteLine("!!!!!!!");
|
||||
Console.WriteLine("Day implementation not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
string[] linesDay = File.ReadAllLines($"inputs/Day{currentDayNumber:00}.txt");
|
||||
try
|
||||
{
|
||||
string resultPart1 = currentDay.ResolvePart1(linesDay);
|
||||
Console.WriteLine("Day{1:00} Result Part1: {0}", resultPart1, currentDayNumber);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
try
|
||||
{
|
||||
string resultPart2 = currentDay.ResolvePart2(linesDay);
|
||||
Console.WriteLine("Day{1:00} Result Part2: {0}", resultPart2, currentDayNumber);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("!!!!!!!");
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
DayHelper.RunDay("AdventOfCode2020", 2);
|
||||
Reference in New Issue
Block a user