File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/AdventOfCode.Cli/Solutions Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
namespace Bussell . AdventOfCode . Solutions ;
2
2
3
+ using System . Runtime . CompilerServices ;
4
+
3
5
public abstract class SolutionWithTextInput : ISolution
4
6
{
5
7
public SolutionWithTextInput ( )
6
8
{
7
- Input = File . ReadAllLines ( InputFileName ) ;
9
+ string basePath = Path . GetDirectoryName ( WhereAmI ( ) )
10
+ ?? throw new InvalidOperationException ( "Could not determine base path." ) ;
11
+ Input = File . ReadAllLines ( Path . Combine ( basePath , InputFileName ) ) ;
8
12
}
9
13
10
14
public abstract int Day { get ; }
11
15
12
16
public abstract string Name { get ; }
13
17
14
- protected string InputFileName => $ "Inputs/{ Day : D2} .txt";
18
+ protected string InputFileName => $ "../ Inputs/{ Day : D2} .txt";
15
19
16
20
protected IEnumerable < string > Input { get ; }
17
21
18
22
public abstract string SolvePart1 ( ) ;
19
23
20
24
public abstract string SolvePart2 ( ) ;
25
+
26
+ private static string WhereAmI ( [ CallerFilePath ] string callerFilePath = "" ) => callerFilePath ;
21
27
}
You can’t perform that action at this time.
0 commit comments