about summary refs log tree commit diff
path: root/Program.cs
blob: 2b98b6da43e6986ccca697951123d4939616aceb (plain) (blame)
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace aoc2019
{
    class Program
    {
        static void Main(string[] args)
        {
            var days = GetDays();

            if (args.Length == 1 && int.TryParse(args[0], out int daynum))
            {
                var d = days.Where(d => d.DayNumber == daynum);
                if (d.Any())
                    d.First().AllParts();
                else
                    Console.WriteLine($"{daynum} invalid or not yet implemented");
            }
            else
            {
                foreach (var d in days)
                {
                    d.AllParts();
                }
            }
        }

        private static IEnumerable<Day> GetDays() =>
            Assembly.GetExecutingAssembly().GetTypes()
                .Where(t => t.BaseType == typeof(Day))
                .Select(t => (Day)Activator.CreateInstance(t));
    }
}