Skip to content

Commit

Permalink
Merge pull request #7 from deckelmouck/someChanges
Browse files Browse the repository at this point in the history
add interface and adjust startup parameters
  • Loading branch information
deckelmouck authored Nov 29, 2023
2 parents a3549c9 + d8d5623 commit 6396e00
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
13 changes: 12 additions & 1 deletion 2022/Day01/solution.cs
Original file line number Diff line number Diff line change
@@ -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");
}
}

8 changes: 8 additions & 0 deletions ISolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace adventofcode;

interface ISolver
{
public void SolvePart1();

public void SolvePart2();
}
18 changes: 17 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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);

Expand Down
25 changes: 25 additions & 0 deletions adventofcode.sln
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6396e00

Please sign in to comment.