Added solution for "Day 21: Step Counter", part 2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
Solutions to the Advent Of Code.
|
||||
Copyright (C) 2023 Stefan Müller
|
||||
Copyright (C) 2023-2024 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
|
||||
@@ -25,10 +25,22 @@ uses
|
||||
Classes, SysUtils, fpcunit, testregistry, USolver, UBaseTestCases, UStepCounter;
|
||||
|
||||
type
|
||||
// Note that the solver implementation does not work with the examples presented
|
||||
// in the puzzle description for part 2, therefore they are not represented here
|
||||
// as test cases.
|
||||
|
||||
{ TStepCounterMax6ExampleTestCase }
|
||||
{ TStepCounterExampleSteps3TestCase }
|
||||
|
||||
TStepCounterMax6ExampleTestCase = class(TExampleEngineBaseTest)
|
||||
TStepCounterExampleSteps3TestCase = class(TExampleEngineBaseTest)
|
||||
protected
|
||||
function CreateSolver: ISolver; override;
|
||||
published
|
||||
procedure TestPart1;
|
||||
end;
|
||||
|
||||
{ TStepCounterExampleSteps6TestCase }
|
||||
|
||||
TStepCounterExampleSteps6TestCase = class(TExampleEngineBaseTest)
|
||||
protected
|
||||
function CreateSolver: ISolver; override;
|
||||
published
|
||||
@@ -37,20 +49,33 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
{ TStepCounterMax6ExampleTestCase }
|
||||
{ TStepCounterExampleSteps3TestCase }
|
||||
|
||||
function TStepCounterMax6ExampleTestCase.CreateSolver: ISolver;
|
||||
function TStepCounterExampleSteps3TestCase.CreateSolver: ISolver;
|
||||
begin
|
||||
Result := TStepCounter.Create(6);
|
||||
Result := TStepCounter.Create(3, 3);
|
||||
end;
|
||||
|
||||
procedure TStepCounterMax6ExampleTestCase.TestPart1;
|
||||
procedure TStepCounterExampleSteps3TestCase.TestPart1;
|
||||
begin
|
||||
AssertEquals(6, FSolver.GetResultPart1);
|
||||
end;
|
||||
|
||||
{ TStepCounterExampleSteps6TestCase }
|
||||
|
||||
function TStepCounterExampleSteps6TestCase.CreateSolver: ISolver;
|
||||
begin
|
||||
Result := TStepCounter.Create(6, 6);
|
||||
end;
|
||||
|
||||
procedure TStepCounterExampleSteps6TestCase.TestPart1;
|
||||
begin
|
||||
AssertEquals(16, FSolver.GetResultPart1);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
RegisterTest('TStepCounter', TStepCounterMax6ExampleTestCase);
|
||||
RegisterTest('TStepCounter', TStepCounterExampleSteps3TestCase);
|
||||
RegisterTest('TStepCounter', TStepCounterExampleSteps6TestCase);
|
||||
end.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user