public void Part01() { var cave = new LavaCave(System.IO.File.ReadAllLines("data/day09.txt").Select(l => l.ToArray().Select(c => int.Parse(char.ToString(c))).ToArray()).ToArray()); cave.Prime(); cave.Heights.Where(h => h.IsLowPoint).Select(h => h.Height + 1).Sum().Should().Be(539); }
public void Part01Example() { var cave = new LavaCave(exampleString.Split("\n") .Select(line => line.ToArray().Select(c => int.Parse(char.ToString(c))).ToArray()) .ToArray()); cave.Prime(); cave.Heights.Where(h => h.IsLowPoint).Select(h => h.Height + 1).Sum().Should().Be(15); }
public void Part02() { var cave = new LavaCave(System.IO.File.ReadAllLines("data/day09.txt").Select(l => l.ToArray().Select(c => int.Parse(char.ToString(c))).ToArray()).ToArray()); cave.Prime(); var step1 = cave.Heights.Where(h => h.IsLowPoint).Select(h => h.BasinSize()).ToArray(); var step2 = step1.OrderByDescending(h => h).ToArray(); var step3 = step2.Take(3).ToArray(); var step4 = step3.Aggregate((a, b) => a * b).Should().Be(736920); }
public void Part02Example() { var cave = new LavaCave(exampleString.Split("\n") .Select(line => line.ToArray().Select(c => int.Parse(char.ToString(c))).ToArray()) .ToArray()); cave.Prime(); var step1 = cave.Heights.Where(h => h.IsLowPoint).Select(h => h.BasinSize()).ToArray(); var step2 = step1.OrderByDescending(h => h).ToArray(); var step3 = step2.Take(3).ToArray(); var step4 = step3.Aggregate((a, b) => a * b).Should().Be(1134); }