104 lines
2.1 KiB
Plaintext
104 lines
2.1 KiB
Plaintext
|
{
|
||
|
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 <http://www.gnu.org/licenses/>.
|
||
|
}
|
||
|
|
||
|
program AdventOfCode;
|
||
|
|
||
|
{$mode objfpc}{$H+}
|
||
|
|
||
|
uses
|
||
|
{$IFDEF UNIX}
|
||
|
cthreads,
|
||
|
{$ENDIF}
|
||
|
Classes, SysUtils, CustApp, UTrebuchet;
|
||
|
|
||
|
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;
|
||
|
begin
|
||
|
TTrebuchet.Solve;
|
||
|
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.
|
||
|
|