Added p/puzzle command line option to run only specific puzzles, and updated the application help text
This commit is contained in:
parent
55f8f3d674
commit
8d5757fae0
|
@ -23,10 +23,11 @@ uses
|
||||||
{$IFDEF UNIX}
|
{$IFDEF UNIX}
|
||||||
cthreads,
|
cthreads,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, CustApp, USolver, UTrebuchet, UCubeConundrum, UGearRatios, UScratchcards, UGiveSeedFertilizer,
|
Classes, SysUtils, CustApp, Generics.Collections, USolver,
|
||||||
UWaitForIt, UCamelCards, UHauntedWasteland, UNumberTheory, UMirageMaintenance, UPipeMaze, UCosmicExpansion,
|
UTrebuchet, UCubeConundrum, UGearRatios, UScratchcards, UGiveSeedFertilizer, UWaitForIt, UCamelCards,
|
||||||
UHotSprings, UPointOfIncidence, UParabolicReflectorDish, ULensLibrary, UFloorWillBeLava, UClumsyCrucible,
|
UHauntedWasteland, UNumberTheory, UMirageMaintenance, UPipeMaze, UCosmicExpansion, UHotSprings, UPointOfIncidence,
|
||||||
ULavaductLagoon, UAplenty, UPulsePropagation;
|
UParabolicReflectorDish, ULensLibrary, UFloorWillBeLava, UClumsyCrucible, ULavaductLagoon, UAplenty,
|
||||||
|
UPulsePropagation;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -48,30 +49,51 @@ type
|
||||||
procedure TAdventOfCode.RunPuzzleSolutions;
|
procedure TAdventOfCode.RunPuzzleSolutions;
|
||||||
var
|
var
|
||||||
engine: TSolverEngine;
|
engine: TSolverEngine;
|
||||||
|
solvers: specialize TList<Integer>;
|
||||||
|
p: string;
|
||||||
|
n: Integer;
|
||||||
begin
|
begin
|
||||||
WriteLn('### Advent of Code 2023 ###');
|
WriteLn('### Advent of Code 2023 ###');
|
||||||
engine := TSolverEngine.Create('data');
|
engine := TSolverEngine.Create('data');
|
||||||
engine.RunAndFree(TTrebuchet.Create);
|
|
||||||
engine.RunAndFree(TCubeConundrum.Create);
|
solvers := specialize TList<Integer>.Create;
|
||||||
engine.RunAndFree(TGearRatios.Create);
|
if HasOption('p', 'puzzle') then
|
||||||
engine.RunAndFree(TScratchcards.Create);
|
begin
|
||||||
engine.RunAndFree(TGiveSeedFertilizer.Create);
|
for p in GetOptionValues('p', 'puzzle') do
|
||||||
engine.RunAndFree(TWaitForIt.Create);
|
if TryStrToInt(p, n) then
|
||||||
engine.RunAndFree(TCamelCards.Create);
|
solvers.Add(n);
|
||||||
engine.RunAndFree(THauntedWasteland.Create);
|
end
|
||||||
engine.RunAndFree(TMirageMaintenance.Create);
|
else
|
||||||
engine.RunAndFree(TPipeMaze.Create);
|
for n := 1 to 25 do
|
||||||
engine.RunAndFree(TCosmicExpansion.Create);
|
solvers.Add(n);
|
||||||
engine.RunAndFree(THotSprings.Create);
|
|
||||||
engine.RunAndFree(TPointOfIncidence.Create);
|
for n in solvers do
|
||||||
engine.RunAndFree(TParabolicReflectorDish.Create);
|
case n of
|
||||||
engine.RunAndFree(TLensLibrary.Create);
|
1: engine.RunAndFree(TTrebuchet.Create);
|
||||||
engine.RunAndFree(TFloorWillBeLava.Create);
|
2: engine.RunAndFree(TCubeConundrum.Create);
|
||||||
engine.RunAndFree(TClumsyCrucible.Create);
|
3: engine.RunAndFree(TGearRatios.Create);
|
||||||
engine.RunAndFree(TLavaductLagoon.Create);
|
4: engine.RunAndFree(TScratchcards.Create);
|
||||||
engine.RunAndFree(TAplenty.Create);
|
5: engine.RunAndFree(TGiveSeedFertilizer.Create);
|
||||||
engine.RunAndFree(TPulsePropagation.Create);
|
6: engine.RunAndFree(TWaitForIt.Create);
|
||||||
|
7: engine.RunAndFree(TCamelCards.Create);
|
||||||
|
8: engine.RunAndFree(THauntedWasteland.Create);
|
||||||
|
9: engine.RunAndFree(TMirageMaintenance.Create);
|
||||||
|
10: engine.RunAndFree(TPipeMaze.Create);
|
||||||
|
11: engine.RunAndFree(TCosmicExpansion.Create);
|
||||||
|
12: engine.RunAndFree(THotSprings.Create);
|
||||||
|
13: engine.RunAndFree(TPointOfIncidence.Create);
|
||||||
|
14: engine.RunAndFree(TParabolicReflectorDish.Create);
|
||||||
|
15: engine.RunAndFree(TLensLibrary.Create);
|
||||||
|
16: engine.RunAndFree(TFloorWillBeLava.Create);
|
||||||
|
17: engine.RunAndFree(TClumsyCrucible.Create);
|
||||||
|
18: engine.RunAndFree(TLavaductLagoon.Create);
|
||||||
|
19: engine.RunAndFree(TAplenty.Create);
|
||||||
|
20: engine.RunAndFree(TPulsePropagation.Create);
|
||||||
|
end;
|
||||||
|
|
||||||
engine.Free;
|
engine.Free;
|
||||||
|
solvers.Free;
|
||||||
|
WriteLn;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAdventOfCode.DoRun;
|
procedure TAdventOfCode.DoRun;
|
||||||
|
@ -79,7 +101,7 @@ var
|
||||||
ErrorMsg: String;
|
ErrorMsg: String;
|
||||||
begin
|
begin
|
||||||
// quick check parameters
|
// quick check parameters
|
||||||
ErrorMsg := CheckOptions('h', 'help');
|
ErrorMsg := CheckOptions('hp:', ['help', 'puzzle:']);
|
||||||
if ErrorMsg <> '' then
|
if ErrorMsg <> '' then
|
||||||
begin
|
begin
|
||||||
ShowException(Exception.Create(ErrorMsg));
|
ShowException(Exception.Create(ErrorMsg));
|
||||||
|
@ -95,7 +117,6 @@ begin
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ add your program here }
|
|
||||||
RunPuzzleSolutions;
|
RunPuzzleSolutions;
|
||||||
|
|
||||||
// stop program loop
|
// stop program loop
|
||||||
|
@ -115,8 +136,13 @@ end;
|
||||||
|
|
||||||
procedure TAdventOfCode.WriteHelp;
|
procedure TAdventOfCode.WriteHelp;
|
||||||
begin
|
begin
|
||||||
{ add your help code here }
|
WriteLn('Usage: ', ExeName, ' [Options]');
|
||||||
writeln('Usage: ', ExeName, ' -h');
|
WriteLn('Options:');
|
||||||
|
WriteLn(' --help, -h');
|
||||||
|
WriteLn(' Shows this usage help.');
|
||||||
|
WriteLn(' --puzzle=<n>, -p <n>');
|
||||||
|
WriteLn(' Instead of running all solvers, only run the one for day <n>.');
|
||||||
|
WriteLn(' Integer from 1 to 25. Can be specified multiple times.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
Loading…
Reference in New Issue