static void Main(string[] args) { Console.WriteLine("Advent 2020\n"); Day[] Days = new Day[26]; Days[1] = new Day1(); Days[2] = new Day2(); Days[3] = new Day3(); Days[4] = new Day4(); Days[5] = new Day5(); Days[6] = new Day6(); Days[7] = new Day7(); Days[8] = new Day8(); Days[9] = new Day9(); Days[10] = new Day10(); Days[11] = new Day11(); Days[12] = new Day12(); Days[13] = new Day13(); Days[14] = new Day14(); Days[15] = new Day15(); Days[16] = new Day16(); Days[17] = new Day17(); Days[18] = new Day18(); Days[19] = new Day19(); Days[20] = new Day20(); Days[21] = new Day21(); Days[22] = new Day22(); Days[23] = new Day23(); Days[24] = new Day24(); Days[25] = new Day25(); string[] argv = System.Environment.GetCommandLineArgs(); if (argv.Length < 2) { for (int i = 1; i < 26; i++) { if (Days[i] != null) { Days[i].Run().Print(); } } } else { for (int i = 1; i < argv.Length; i++) { int day; if (int.TryParse(argv[i], out day) && day > 0 && day < 26 && Days[day] != null) { Days[day].Run().Print(); } } } }
public static void startDay1() { Console.WriteLine("Press ENTER to continue..."); Console.ReadKey(); string filePath = @"C:\Users\Sam\Downloads\input.txt"; // create a string[] and use the method to get a value string[] lines = Day1.getFileText(filePath); // printLinesText(lines); int fileLength = Day1.getFileLength(filePath); //printLinesInt(convertToIntArray(lines, fileLength)); Console.WriteLine(Day1.getAnswerSum(Day1.convertToIntArray(lines, fileLength), fileLength)); }
static void Main(string[] args) { Console.WriteLine("What day's challenge would you like to run?"); string input; do { input = Console.ReadLine(); switch (input) { case "1": var day1 = new Day1(); var day1Results = day1.GetSolution(); Program.PrintSolution(day1Results.solution, day1Results.bonus); break; case "2": var day2 = new Day2(); var day2Results = day2.GetSolution(); Program.PrintSolution(day2Results.solution, day2Results.bonus); break; case "3": var day3 = new Day3(); var day3Results = day3.GetSolution(); Program.PrintSolution(day3Results.solution, day3Results.bonus); break; case "q": Console.WriteLine("Later."); break; default: Console.WriteLine("Invalid input."); break; } }while (input != "q"); }