public void Test_DayOnePartTwoExample() { var input = "199\n" + "200\n" + "208\n" + "210\n" + "200\n" + "207\n" + "240\n" + "269\n" + "260\n" + "263"; var sweeper = new SonarSweep(input.ToIntArray("\n").ToList()); Assert.AreEqual(8, sweeper.Windows.Count()); Assert.AreEqual(5, sweeper.GetIncreaseCount(sweeper.Windows)); }
public void Test_DayOnePartOneExample() { var input = "199\n" + "200\n" + "208\n" + "210\n" + "200\n" + "207\n" + "240\n" + "269\n" + "260\n" + "263"; var sweeper = new SonarSweep(input.ToIntArray("\n").ToList()); Assert.AreEqual(10, sweeper.Measurements.Count()); Assert.AreEqual(7, sweeper.GetIncreaseCount(sweeper.Measurements)); }
public async Task Test_CountIncreasingSlidingWindows(int slidingWindow, string file) { // Arrange var textLines = await File.ReadAllLinesAsync(file); var puzzleInput = textLines .Where(line => !string.IsNullOrWhiteSpace(line)) .Select(line => int.Parse(line)) .ToList(); var sonarScanner = new SonarSweep(); // Act var increasingCount = sonarScanner.CountIncreasingMeasurementsWithSlidingWindow(puzzleInput, slidingWindow); // Assert Assert.IsTrue(increasingCount > 0); Assert.IsTrue(increasingCount < puzzleInput.Count()); Debug.WriteLine(increasingCount); }
public Day01() : base(01, 2021, "Sonar Sweep") { SonarSweep = new SonarSweep(Input.ToIntArray("\n").ToList()); }