Added solution for "Day 11: Cosmic Expansion", part 2
This commit is contained in:
@@ -26,8 +26,8 @@ uses
|
||||
|
||||
const
|
||||
CGalaxyChar = '#';
|
||||
CEmptySpaceFactor = 2;
|
||||
CNonEmptySpaceFactor = 1;
|
||||
CEmptySpaceFactor = 1;
|
||||
CNonEmptySpaceFactor = 0;
|
||||
|
||||
type
|
||||
|
||||
@@ -45,6 +45,7 @@ type
|
||||
procedure Finish; override;
|
||||
function GetDataFileName: string; override;
|
||||
function GetPuzzleName: string; override;
|
||||
function GetExpansionFactor: Integer; virtual;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@@ -107,9 +108,15 @@ begin
|
||||
for i := 0 to FGalaxies.Count - 1 do
|
||||
for j := i + 1 to FGalaxies.Count - 1 do begin
|
||||
for k := Min(FGalaxies[i].X, FGalaxies[j].X) to Max(FGalaxies[i].X, FGalaxies[j].X) - 1 do
|
||||
Inc(FPart1, FColumnExpansion[k]);
|
||||
begin
|
||||
Inc(FPart1, 1 + FColumnExpansion[k]);
|
||||
Inc(FPart2, 1 + FColumnExpansion[k] * GetExpansionFactor);
|
||||
end;
|
||||
for k := Min(FGalaxies[i].Y, FGalaxies[j].Y) + 1 to Max(FGalaxies[i].Y, FGalaxies[j].Y) do
|
||||
Inc(FPart1, FRowExpansion[k]);
|
||||
begin
|
||||
Inc(FPart1, 1 + FRowExpansion[k]);
|
||||
Inc(FPart2, 1 + FRowExpansion[k] * GetExpansionFactor);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -123,5 +130,10 @@ begin
|
||||
Result := 'Day 11: Cosmic Expansion';
|
||||
end;
|
||||
|
||||
function TCosmicExpansion.GetExpansionFactor: Integer;
|
||||
begin
|
||||
Result := 999999;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user