public static string GetName(this IAdventOfCode aoc) { return(( aoc .GetType() .GetCustomAttribute(typeof(CodeName)) as CodeName ).Name); }
public static void Run(IAdventOfCode aoc) { var input = aoc.ReadInputFile(); var result1 = aoc.First(input); var result2 = aoc.Second(input); ConsoleHelper.WriteHelloMessageAndResult(aoc.Day(), aoc.GetName(), result1, result2); }
public static List <string> ReadInputFile(this IAdventOfCode aoc, bool testfile = false) { var dir = aoc.WorkingDir(); var filename = testfile ? "input_test.txt" : "input.txt"; var path = Path.Combine(dir, filename); if (File.Exists(path)) { return(System.IO.File.ReadAllLines(path).ToList()); } Console.WriteLine($"WARNING: file not found.. {path}"); return(new List <string>()); }
public static void Run(IAdventOfCode aocIn, bool test) { if (!test) { RunOnlyResult(aocIn); return; } var aoc = aocIn as IAdventOfCodeWithTest; var inputTest = aoc.ReadInputFile(true); var testResult1 = aoc.Test(inputTest); var testResult2 = aoc.Test2(inputTest); if (testResult1.succeded && testResult2.succeded) { RunOnlyResult(aoc); return; } ConsoleHelper.WriteHelloMessage(aoc.Day(), aoc.GetName()); // FIRST ConsoleHelper.WriteTestResultMessage("Test1", testResult1); ConsoleHelper.WriteBreakLine(); var inputOrg = aoc.ReadInputFile(); var result1 = aoc.First(inputOrg); ConsoleHelper.WriteResultMessage("FIRST", result1); ConsoleHelper.WriteBreakLine(); // SECOND ConsoleHelper.WriteTestResultMessage("Test2", testResult2); ConsoleHelper.WriteBreakLine(); var result2 = aoc.Second(inputOrg); ConsoleHelper.WriteResultMessage("SECOND", result2); }
public static string WorkingDir(this IAdventOfCode aoc) { return(WorkingDir(aoc.Year(), aoc.Day())); }
public static int Day(this IAdventOfCode aoc) { var t = aoc.GetType(); return(int.Parse(t.FullName.Split('.')[2].Substring(1))); }
public static string DayName(this IAdventOfCode aoc) { return($"Dec {aoc.Day()}"); }