misc refactoring
This commit is contained in:
@@ -8,7 +8,7 @@ internal class Program
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var runner = new AOCRunner();
|
var runner = new AOCRunner();
|
||||||
//runner.RenderMenu();
|
runner.RenderMenu();
|
||||||
var cc = new CalorieCounting();
|
var cc = new CalorieCounting();
|
||||||
cc.LoadInput();
|
cc.LoadInput();
|
||||||
cc.CalculatePart1();
|
cc.CalculatePart1();
|
||||||
|
|||||||
@@ -24,11 +24,13 @@ public class AOCRunner
|
|||||||
var info = type.GetCustomAttribute<ProblemInfoAttribute>();
|
var info = type.GetCustomAttribute<ProblemInfoAttribute>();
|
||||||
if (info == null)
|
if (info == null)
|
||||||
continue;
|
continue;
|
||||||
if (_loadedProblems.ContainsKey(info.Year))
|
if (_loadedProblems.TryGetValue(info.Year, out var list))
|
||||||
_loadedProblems[info.Year].Add((info, type));
|
list.Add((info, type));
|
||||||
else
|
else
|
||||||
_loadedProblems.Add(info.Year, new() { (info, type) });
|
_loadedProblems.Add(info.Year, new() { (info, type) });
|
||||||
}
|
}
|
||||||
|
foreach (var (year, list) in _loadedProblems)
|
||||||
|
_loadedProblems[year] = list.OrderBy(l => l.info.Day).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderMenu()
|
public void RenderMenu()
|
||||||
@@ -37,16 +39,19 @@ public class AOCRunner
|
|||||||
|
|
||||||
Console.WriteLine("Available Problems:");
|
Console.WriteLine("Available Problems:");
|
||||||
foreach (var year in years)
|
foreach (var year in years)
|
||||||
|
RenderYearMenu(year);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RenderYearMenu(string year)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.WriteLine($"{year}:");
|
||||||
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
|
var days = _loadedProblems[year];
|
||||||
|
for (int i = 0; i < days.Count; i++)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
var (info, type) = days[i];
|
||||||
Console.WriteLine($"{year}:");
|
Console.WriteLine($"\tDay {info.Day} - {info.Name}");
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
|
||||||
var days = _loadedProblems[year];
|
|
||||||
for (int i = 0; i < days.Count; i++)
|
|
||||||
{
|
|
||||||
var day = days[i];
|
|
||||||
Console.WriteLine($"\tDay {day.info.Day} - {day.info.Name}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user