-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day1.cs
38 lines (32 loc) · 937 Bytes
/
Day1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace AdventOfCode
{
public static class Day1
{
public static int Part1()
{
List<int> data = DataService.GetDay1Data();
return CalculateDepthIncreases(data);
}
public static int Part2()
{
List<int> data = DataService.GetDay1Data();
List<int> smoothedData = new();
for (int i = 0; i < data.Count - 2; i++)
{
int r = data.GetRange(i, 3).Sum();
smoothedData.Add(r);
}
return CalculateDepthIncreases(smoothedData);
}
private static int CalculateDepthIncreases(List<int> input)
{
int depthIncreases = 0;
for (int i = 1; i < input.Count; i++)
{
if (input[i] > input[i - 1])
depthIncreases++;
}
return depthIncreases;
}
}
}