Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
49 lines (46 loc) · 1.76 KB
/
Copy pathProgram.cs
File metadata and controls
49 lines (46 loc) · 1.76 KB
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
41
42
43
44
45
46
47
48
49
#nullable disable
using System.Reflection;
class Program
{
private static void Main(string[] args)
{
int day = 1;
int part = 1;
int currentDay = 20;
if (args.Length == 1 && args[0] == "A")
{
var watch = System.Diagnostics.Stopwatch.StartNew();
for(int i = 1; i <= currentDay; i++)
{
Type classType = Type.GetType($"Day{i}");
for (int j = 1; j <= 2; j++) {
Console.WriteLine($"Running Day {i}-{j}");
MethodInfo method = classType.GetMethod($"Solve{j}");
var funcWatch = System.Diagnostics.Stopwatch.StartNew();
method.Invoke(null, null);
Console.WriteLine($"Run time = {funcWatch.ElapsedMilliseconds}ms \n");
}
}
watch.Stop();
Console.WriteLine($"Total run time = {watch.ElapsedMilliseconds}ms");
}
else{
if (args.Length != 2) {
Console.WriteLine("Please select a day to run: [1..25]");
day = int.Parse(Console.ReadLine());
Console.WriteLine("Part 1 or Part 2?");
part = int.Parse(Console.ReadLine());
}
else {
day = int.Parse(args[0]);
part = int.Parse(args[1]);
}
Console.WriteLine($"Running Day {day}-{part}");
Type classType = Type.GetType($"Day{day}");
MethodInfo method = classType.GetMethod($"Solve{part}");
var funcWatch = System.Diagnostics.Stopwatch.StartNew();
method.Invoke(null, null);
Console.WriteLine($"Run time = {funcWatch.ElapsedMilliseconds}ms \n");
}
}
}