2022 day 1
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
2de2266e18
commit
514a902829
|
@ -5,7 +5,7 @@ namespace AOC.Test;
|
|||
public class Test2022
|
||||
{
|
||||
[DataTestMethod]
|
||||
[DataRow(typeof(Day01), "", "")]
|
||||
[DataRow(typeof(Day01), "70509", "208567")]
|
||||
public void CheckAllDays(Type dayType, string part1, string part2)
|
||||
{
|
||||
Common.CheckDay(dayType, part1, part2);
|
||||
|
|
|
@ -3,19 +3,35 @@
|
|||
/// <summary>
|
||||
/// Day 1: <see href="https://adventofcode.com/2022/day/1"/>
|
||||
/// </summary>
|
||||
public sealed class Day01 : Day
|
||||
public sealed class Day01 : Day, IDay01
|
||||
{
|
||||
private readonly List<List<int>> _elfCalories = new();
|
||||
|
||||
public Day01() : base(2022, 1, "Day 1 Puzzle Name")
|
||||
{
|
||||
var elf = new List<int>();
|
||||
|
||||
foreach (var line in Input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
_elfCalories.Add(elf);
|
||||
elf = new();
|
||||
}
|
||||
else
|
||||
elf.Add(int.Parse(line));
|
||||
}
|
||||
|
||||
if (elf.Any()) _elfCalories.Add(elf);
|
||||
}
|
||||
|
||||
public override object Part1()
|
||||
{
|
||||
return "";
|
||||
return _elfCalories.OrderByDescending(e => e.Sum()).First().Sum();
|
||||
}
|
||||
|
||||
public override object Part2()
|
||||
{
|
||||
return "";
|
||||
return _elfCalories.OrderByDescending(e => e.Sum()).Take(3).Sum(e => e.Sum());
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,14 @@
|
|||
1000
|
||||
2000
|
||||
3000
|
||||
|
||||
4000
|
||||
|
||||
5000
|
||||
6000
|
||||
|
||||
7000
|
||||
8000
|
||||
9000
|
||||
|
||||
10000
|
Loading…
Reference in New Issue