{ Solutions to the Advent Of Code. Copyright (C) 2023 Stefan Müller This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . } program AdventOfCode; {$mode objfpc}{$H+} uses {$IFDEF UNIX} cthreads, {$ENDIF} Classes, SysUtils, CustApp, USolver, UTrebuchet, UCubeConundrum, UGearRatios, UScratchcards, UGiveSeedFertilizer, UWaitForIt, UCamelCards, UHauntedWasteland, UNumberTheory, UMirageMaintenance, UPipeMaze, UCosmicExpansion, UHotSprings, UPointOfIncidence; type { TAdventOfCode } TAdventOfCode = class(TCustomApplication) private procedure RunPuzzleSolutions; protected procedure DoRun; override; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; procedure WriteHelp; virtual; end; { TAdventOfCode } procedure TAdventOfCode.RunPuzzleSolutions; var engine: TSolverEngine; begin WriteLn('### Advent of Code 2023 ###'); engine := TSolverEngine.Create('data'); engine.RunAndFree(TTrebuchet.Create); engine.RunAndFree(TCubeConundrum.Create); engine.RunAndFree(TGearRatios.Create); engine.RunAndFree(TScratchcards.Create); engine.RunAndFree(TGiveSeedFertilizer.Create); engine.RunAndFree(TWaitForIt.Create); engine.RunAndFree(TCamelCards.Create); engine.RunAndFree(THauntedWasteland.Create); engine.RunAndFree(TMirageMaintenance.Create); engine.RunAndFree(TPipeMaze.Create); engine.RunAndFree(TCosmicExpansion.Create); engine.RunAndFree(THotSprings.Create); engine.RunAndFree(TPointOfIncidence.Create); engine.Free; end; procedure TAdventOfCode.DoRun; var ErrorMsg: String; begin // quick check parameters ErrorMsg := CheckOptions('h', 'help'); if ErrorMsg <> '' then begin ShowException(Exception.Create(ErrorMsg)); Terminate; Exit; end; // parse parameters if HasOption('h', 'help') then begin WriteHelp; Terminate; Exit; end; { add your program here } RunPuzzleSolutions; // stop program loop Terminate; end; constructor TAdventOfCode.Create(TheOwner: TComponent); begin inherited Create(TheOwner); StopOnException := True; end; destructor TAdventOfCode.Destroy; begin inherited Destroy; end; procedure TAdventOfCode.WriteHelp; begin { add your help code here } writeln('Usage: ', ExeName, ' -h'); end; var Application: TAdventOfCode; begin Application := TAdventOfCode.Create(nil); Application.Title := 'Advent of Code 2023'; Application.Run; Application.Free; end.