misc fixes
This commit is contained in:
@@ -3,7 +3,7 @@ using AdventOfCode.Runner.Attributes;
|
||||
|
||||
namespace AdventOfCode.Problems.AOC2022.Day0;
|
||||
[ProblemInfo("2022", 0, "Fancy Test")]
|
||||
public class TestProblem : IProblemBase
|
||||
public class TestProblem : IProblem
|
||||
{
|
||||
public void LoadInput()
|
||||
{
|
||||
|
||||
@@ -9,13 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AdventOfCode.Problems.AOC2022.Day1;
|
||||
[ProblemInfo("2022", 1, "Calorie Counting")]
|
||||
internal class CalorieCounting : IProblemBase
|
||||
internal class CalorieCounting : IProblem
|
||||
{
|
||||
private (int calories, int elf) mostestElf;
|
||||
private IEnumerable<(int sum, int idx)> mostestElves;
|
||||
|
||||
public List<List<int>> FlaresFood { get; set; }
|
||||
|
||||
private (int calories, int elf)? _mostestElf;
|
||||
private IEnumerable<(int sum, int idx)>? _mostestElves;
|
||||
|
||||
public CalorieCounting() {
|
||||
FlaresFood = new List<List<int>>
|
||||
{
|
||||
@@ -40,14 +40,14 @@ internal class CalorieCounting : IProblemBase
|
||||
}
|
||||
public void CalculatePart1()
|
||||
{
|
||||
mostestElf = FlaresFood
|
||||
_mostestElf = FlaresFood
|
||||
.Select((x, idx) => (sum: x.Sum(), idx))
|
||||
.MaxBy(x => x.sum);
|
||||
}
|
||||
|
||||
public void CalculatePart2()
|
||||
{
|
||||
mostestElves = FlaresFood
|
||||
_mostestElves = FlaresFood
|
||||
.Select((x, idx) => (sum: x.Sum(), idx))
|
||||
.OrderByDescending(e => e.sum)
|
||||
.Take(3);
|
||||
@@ -56,14 +56,24 @@ internal class CalorieCounting : IProblemBase
|
||||
|
||||
public void PrintPart1()
|
||||
{
|
||||
Console.WriteLine($"Mostest: {mostestElf}");
|
||||
if (_mostestElf == null)
|
||||
{
|
||||
Console.WriteLine("Part 1 has not been calculated");
|
||||
return;
|
||||
}
|
||||
Console.WriteLine($"Mostest: {_mostestElf}");
|
||||
}
|
||||
|
||||
public void PrintPart2()
|
||||
{
|
||||
if(_mostestElves == null)
|
||||
{
|
||||
Console.WriteLine("Part 2 has not been calculated");
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("Top Elves");
|
||||
foreach (var elf in mostestElves)
|
||||
foreach (var elf in _mostestElves)
|
||||
Console.WriteLine($"\t{elf}");
|
||||
Console.WriteLine($"Total {mostestElves.Sum(e => e.sum)}");
|
||||
Console.WriteLine($"Total {_mostestElves.Sum(e => e.sum)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using AdventOfCode.Runner.Attributes;
|
||||
|
||||
namespace AdventOfCode.Problems.AOC2023.Day0;
|
||||
[ProblemInfo("2023", 0, "Test")]
|
||||
public class TestProblem : IProblemBase
|
||||
public class TestProblem : IProblem
|
||||
{
|
||||
public void LoadInput()
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ public class AOCRunner
|
||||
|
||||
private void FindProblemClasses()
|
||||
{
|
||||
var types = Assembly.GetExecutingAssembly().DefinedTypes.Where(t => t.IsAssignableTo(typeof(IProblemBase)) && !t.IsInterface);
|
||||
var types = Assembly.GetExecutingAssembly().DefinedTypes.Where(t => t.IsAssignableTo(typeof(IProblem)) && !t.IsInterface);
|
||||
if (types == null)
|
||||
return;
|
||||
foreach (var type in types)
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AdventOfCode.Runner;
|
||||
public interface IProblemBase
|
||||
public interface IProblem
|
||||
{
|
||||
void LoadInput();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user