-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (38 loc) · 1.58 KB
/
Program.cs
File metadata and controls
44 lines (38 loc) · 1.58 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
using AdventOfCode.Interfaces;
using System;
using System.Diagnostics;
using System.IO;
namespace AdventOfCode
{
class Program
{
private const int DayToSolve = 25;
static void Main(string[] args)
{
// Create solver
var solverTypeName = "AdventOfCode.Day" + DayToSolve.ToString("D2");
var solverType = Type.GetType(solverTypeName);
if (solverType == null)
{
Console.WriteLine($"Invalid type: {solverTypeName}");
return;
}
var solver = Activator.CreateInstance(solverType) as ISolver;
// Read first input file
var firstStarFilePath = Path.Combine(solver.GetType().Name, solver.InputFileName);
var firstStarFileReader = File.OpenText(firstStarFilePath);
var stopWatch = Stopwatch.StartNew();
var firstStarResult = solver.SolveFirstStar(firstStarFileReader);
stopWatch.Stop();
Console.WriteLine($"First star result: {firstStarResult}, {stopWatch.ElapsedMilliseconds}ms");
// Read second input file
var secondStarFilePath = Path.Combine(solver.GetType().Name, solver.InputFileName);
var secondStarFileReader = File.OpenText(secondStarFilePath);
stopWatch.Reset();
stopWatch.Start();
var secondStarResult = solver.SolveSecondStar(secondStarFileReader);
stopWatch.Stop();
Console.WriteLine($"Second star result: {secondStarResult}, {stopWatch.ElapsedMilliseconds}ms");
}
}
}