diff --git a/AdventOfCode.lpr b/AdventOfCode.lpr index 83e2617..3a77065 100644 --- a/AdventOfCode.lpr +++ b/AdventOfCode.lpr @@ -51,7 +51,7 @@ begin WriteLn('### Advent of Code 2023 ###'); TTrebuchet.Run; TCubeConundrum.Run; - engine := TSolverEngine.Create; + engine := TSolverEngine.Create('data'); engine.RunAndFree(TGearRatios.Create); engine.Free; end; diff --git a/USolver.pas b/USolver.pas index 5eacddf..d47a893 100644 --- a/USolver.pas +++ b/USolver.pas @@ -62,7 +62,10 @@ type { TSolverEngine } TSolverEngine = class + private + FRelativeDataPath: string; public + constructor Create(const ARelativeDataPath: string); procedure ProcessData(const ASolver: ISolver); procedure Run(const ASolver: ISolver); procedure RunAndFree(const ASolver: ISolver); @@ -90,6 +93,11 @@ end; { TSolverEngine } +constructor TSolverEngine.Create(const ARelativeDataPath: string); +begin + FRelativeDataPath := ARelativeDataPath; +end; + procedure TSolverEngine.ProcessData(const ASolver: ISolver); var data: TextFile; @@ -97,7 +105,7 @@ var begin ASolver.Init; - AssignFile(data, ConcatPaths(['data', ASolver.DataFileName])); + AssignFile(data, ConcatPaths([FRelativeDataPath, ASolver.DataFileName])); try reset(data); while (not EOF(data)) do