d18p2
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Ben Harris 2021-12-18 10:59:07 -05:00
parent 0455ee883d
commit 9daa1e1424
2 changed files with 15 additions and 3 deletions

View File

@ -38,7 +38,7 @@ public class DayTests
[DataRow(typeof(Day15), "702", "2955")]
[DataRow(typeof(Day16), "852", "19348959966392")]
[DataRow(typeof(Day17), "12090", "5059")]
[DataRow(typeof(Day18), "4289", "")]
[DataRow(typeof(Day18), "4289", "4807")]
public void CheckAllDays(Type dayType, string part1, string part2)
{
var s = Stopwatch.StartNew();
@ -86,7 +86,7 @@ public class DayTests
[DataRow(typeof(Day15), "40", "315")]
[DataRow(typeof(Day16), "16", "15")]
[DataRow(typeof(Day17), "45", "112")]
[DataRow(typeof(Day18), "4140", "")]
[DataRow(typeof(Day18), "4140", "3993")]
public void CheckTestInputs(Type dayType, string part1, string part2)
{
Day.UseTestInput = true;

View File

@ -112,5 +112,17 @@ public sealed class Day18 : Day
return Magnitude(result.Root);
}
public override object Part2() => "";
public override object Part2()
{
var best = 0L;
for (var i = 0; i < _fishes.Count; i++)
best = _fishes
.Where((_, j) => i != j)
.Select(t => Add(Parse(_fishes[i]), Parse(t)))
.Select(result => Magnitude(result.Root))
.Prepend(best)
.Max();
return best;
}
}