-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
40 lines (27 loc) · 1.02 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// See https://aka.ms/new-console-template for more information
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using AdventOfCode2021;
using AdventOfCode2021.Excercises;
Dictionary<int, Dictionary<int, ExcerciseBase>> LoadExcercies()
{
Dictionary<int, Dictionary<int, ExcerciseBase>> excercises = new ();
var types = Assembly.GetAssembly(typeof(ExcerciseBase))?.GetTypes().Where(t => t.IsSubclassOf(typeof(ExcerciseBase))).ToList();
foreach (Type t in types)
{
ExcerciseBase baseType = (ExcerciseBase)Activator.CreateInstance(t);
if (!excercises.ContainsKey(baseType.Day))
{
excercises[baseType.Day] = new Dictionary<int, ExcerciseBase>();
}
excercises[baseType.Day][baseType.Part] = baseType;
}
return excercises;
}
var excercises = LoadExcercies();
int day = Convert.ToInt32(args[0]);
int part = Convert.ToInt32(args[1]);
Console.WriteLine($"Running day {day} - part {part}");
excercises[day][part].Run();