2021-11-11 05:19:35 +00:00
|
|
|
|
namespace aoc2021;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Day 1: <see href="https://adventofcode.com/2021/day/1"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class Day01 : Day
|
|
|
|
|
{
|
2021-12-01 05:42:20 +00:00
|
|
|
|
private readonly List<int> _readings;
|
|
|
|
|
|
|
|
|
|
public Day01() : base(1, "Sonar Sweep")
|
2021-11-11 05:19:35 +00:00
|
|
|
|
{
|
2021-12-01 05:42:20 +00:00
|
|
|
|
_readings = Input.Select(int.Parse).ToList();
|
2021-11-11 05:19:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:26:25 +00:00
|
|
|
|
public override string Part1() =>
|
|
|
|
|
Enumerable.Range(0, _readings.Count - 1).Count(i => _readings[i + 1] > _readings[i]).ToString();
|
2021-11-11 05:19:35 +00:00
|
|
|
|
|
2021-12-01 15:26:25 +00:00
|
|
|
|
public override string Part2() =>
|
|
|
|
|
Enumerable.Range(0, _readings.Count - 3).Count(i => _readings[i + 3] > _readings[i]).ToString();
|
2021-11-11 05:19:35 +00:00
|
|
|
|
}
|