File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
AdventOfCode/Solutions/Year2024 Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change 1111
1212namespace 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+ }
You can’t perform that action at this time.
0 commit comments