Skip to content

Commit cf7c4cd

Browse files
committed
2024 Day 01, back in the saddle again.
1 parent 0dee021 commit cf7c4cd

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

AdventOfCode/Solutions/Year2024/Day01-Solution.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,32 @@
1111

1212
namespace AdventOfCode.Solutions.Year2024
1313
{
14-
[DayInfo(01, 2024, "")]
14+
[DayInfo(01, 2024, "Historian Hysteria")]
1515
class Day01 : ASolution
1616
{
17+
List<int> list1 = new();
18+
List<int> list2 = new();
19+
1720
public Day01() : base()
1821
{
19-
22+
foreach(var l in Input.SplitByNewline())
23+
{
24+
var ints = l.ExtractPosInts().ToArray();
25+
list1.Add(ints[0]);
26+
list2.Add(ints[1]);
27+
}
28+
list1.Sort();
29+
list2.Sort();
2030
}
2131

2232
protected override object SolvePartOne()
2333
{
24-
return null;
34+
return list1.Zip(list2).Sum(a => Math.Abs(a.First-a.Second));
2535
}
2636

2737
protected override object SolvePartTwo()
2838
{
29-
return null;
39+
return list1.Sum(a => a * list2.Count(b => a == b));
3040
}
3141
}
32-
}
42+
}

0 commit comments

Comments
 (0)