From d8d562345fbac5a3b73bb9d6ed3720fc161b96ba Mon Sep 17 00:00:00 2001 From: deckelmouck Date: Wed, 29 Nov 2023 06:24:44 +0100 Subject: [PATCH] add interface and adjust startup parameters --- 2022/Day01/solution.cs | 13 ++++++++++++- ISolver.cs | 8 ++++++++ Program.cs | 18 +++++++++++++++++- adventofcode.sln | 25 +++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 ISolver.cs create mode 100644 adventofcode.sln diff --git a/2022/Day01/solution.cs b/2022/Day01/solution.cs index 5d4d544..4c91ed5 100644 --- a/2022/Day01/solution.cs +++ b/2022/Day01/solution.cs @@ -1,11 +1,22 @@ using System; +using adventofcode; namespace aoc2022; -public class solutionDay01 +public class solutionDay01 : ISolver { public void Solve() { Console.WriteLine("solve test"); } + + public void SolvePart1() + { + Console.WriteLine("try to solve first part"); + } + + public void SolvePart2() + { + Console.WriteLine("try to solve second part"); + } } diff --git a/ISolver.cs b/ISolver.cs new file mode 100644 index 0000000..5832872 --- /dev/null +++ b/ISolver.cs @@ -0,0 +1,8 @@ +namespace adventofcode; + +interface ISolver +{ + public void SolvePart1(); + + public void SolvePart2(); +} \ No newline at end of file diff --git a/Program.cs b/Program.cs index 0bb29bb..8d857e0 100644 --- a/Program.cs +++ b/Program.cs @@ -24,6 +24,12 @@ static void Main(string[] args) solve(year, day, part); } + else if (args.Length == 2) + { + year = Convert.ToInt32(args[0]); + day = Convert.ToInt32(args[1]); + solve(year, day); + } else { //solutionDay1 sd1 = new solutionDay1(2); @@ -42,6 +48,13 @@ static void Main(string[] args) //Console.Read(); } + static void solve(int year, int day) + { + solve(year, day, 1); + + solve(year, day, 2); + } + static void solve(int year, int day, int part) { if(year == 2022) @@ -51,10 +64,13 @@ static void solve(int year, int day, int part) Console.WriteLine("{0}", assembly.FullName); + var solution = $"aoc{year.ToString("D4")}.solutionDay{day.ToString("D2")}"; + Console.WriteLine(solution); + Type type = assembly.GetType("aoc2022.solutionDay01"); object instance = Activator.CreateInstance(type); - MethodInfo solve = type.GetMethod("Solve"); + MethodInfo solve = type.GetMethod($"SolvePart{part.ToString("D1")}"); solve.Invoke(instance, null); diff --git a/adventofcode.sln b/adventofcode.sln new file mode 100644 index 0000000..c630f57 --- /dev/null +++ b/adventofcode.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adventofcode", "adventofcode.csproj", "{A10E754C-6C5C-47F2-BB15-A65DD7D8137E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A10E754C-6C5C-47F2-BB15-A65DD7D8137E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A10E754C-6C5C-47F2-BB15-A65DD7D8137E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A10E754C-6C5C-47F2-BB15-A65DD7D8137E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A10E754C-6C5C-47F2-BB15-A65DD7D8137E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D9C9B872-4034-4045-9836-1668F74D81DB} + EndGlobalSection +EndGlobal