File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,12 @@ public object PartOne(string input) =>
12
12
public object PartTwo ( string input ) =>
13
13
Solve ( input , @"\d|one|two|three|four|five|six|seven|eight|nine" ) ;
14
14
15
- int Solve ( string input , string rx ) =>
16
- input . Split ( "\n " ) . Select ( line => GetNumber ( line , rx ) ) . Sum ( ) ;
17
-
18
- int GetNumber ( string line , string rx ) {
19
- var first = Regex . Match ( line , rx ) ;
20
- var last = Regex . Match ( line , rx , RegexOptions . RightToLeft ) ;
21
- return ParseMatch ( first . Value ) * 10 + ParseMatch ( last . Value ) ;
22
- }
15
+ int Solve ( string input , string rx ) => (
16
+ from line in input . Split ( "\n " )
17
+ let first = Regex . Match ( line , rx )
18
+ let last = Regex . Match ( line , rx , RegexOptions . RightToLeft )
19
+ select ParseMatch ( first . Value ) * 10 + ParseMatch ( last . Value )
20
+ ) . Sum ( ) ;
23
21
24
22
int ParseMatch ( string st ) => st switch {
25
23
"" => 0 , // no match
You can’t perform that action at this time.
0 commit comments