Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions exercises/matrix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ So given a string with embedded newlines like:
representing this matrix:

```text
0 1 2
1 2 3
|---------
0 | 9 8 7
1 | 5 3 2
2 | 6 6 7
1 | 9 8 7
2 | 5 3 2
3 | 6 6 7
```

your code should be able to spit out:
Expand Down
4 changes: 2 additions & 2 deletions exercises/matrix/uMatrixExample.pas
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function TMatrix.Column(AInd: integer): TArray<integer>;
begin
SetLength(Result, Length(FMat));
for i := Low(FMat) to High(FMat) do
Result[i] := FMat[i, AInd];
Result[i] := FMat[i, AInd - 1];
end;

constructor TMatrix.Create(AMatr: string);
Expand All @@ -42,7 +42,7 @@ constructor TMatrix.Create(AMatr: string);

function TMatrix.Row(AInd: integer): TArray<integer>;
begin
Result := FMat[AInd];
Result := FMat[AInd - 1];
end;

end.
19 changes: 10 additions & 9 deletions exercises/matrix/uMatrixTest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface
DUnitX.TestFramework, System.Generics.Collections;

const
CanonicalVersion = '1.0.0';
CanonicalVersion = '1.1.0';

type

Expand All @@ -18,6 +18,7 @@ TMatrixTest = class(TObject)
public
[Setup]
procedure Setup;

[TearDown]
procedure TearDown;

Expand Down Expand Up @@ -66,7 +67,7 @@ procedure TMatrixTest.can_extract_column;
ExpectedRow.AddRange([3, 6, 9]);
Expected := ExpectedRow.ToArray;
CUT := TMatrix.Create('1 2 3\n4 5 6\n7 8 9');
Actual := CUT.column(2);
Actual := CUT.column(3);
CompareArrays(Expected, Actual);
end;

Expand All @@ -79,7 +80,7 @@ procedure TMatrixTest.can_extract_column_from_non_square_matrix;
ExpectedRow.AddRange([3, 6, 9, 6]);
Expected := ExpectedRow.ToArray;
CUT := TMatrix.Create('1 2 3\n4 5 6\n7 8 9\n8 7 6');
Actual := CUT.column(2);
Actual := CUT.column(3);
CompareArrays(Expected, Actual);
end;

Expand All @@ -92,7 +93,7 @@ procedure TMatrixTest.can_extract_row;
ExpectedRow.AddRange([3, 4]);
Expected := ExpectedRow.ToArray;
CUT := TMatrix.Create('1 2\n3 4');
Actual := CUT.Row(1);
Actual := CUT.Row(2);
CompareArrays(Expected, Actual);
end;

Expand All @@ -105,7 +106,7 @@ procedure TMatrixTest.can_extract_row_from_non_square_matrix;
ExpectedRow.AddRange([7, 8, 9]);
Expected := ExpectedRow.ToArray;
CUT := TMatrix.Create('1 2 3\n4 5 6\n7 8 9\n8 7 6');
Actual := CUT.Row(2);
Actual := CUT.Row(3);
CompareArrays(Expected, Actual);
end;

Expand All @@ -118,7 +119,7 @@ procedure TMatrixTest.extract_column_from_one_number_matrix;
ExpectedRow.AddRange([1]);
Expected := ExpectedRow.ToArray;
CUT := TMatrix.Create('1');
Actual := CUT.column(0);
Actual := CUT.column(1);
CompareArrays(Expected, Actual);
end;

Expand All @@ -131,7 +132,7 @@ procedure TMatrixTest.extract_column_where_numbers_have_different_widths;
ExpectedRow.AddRange([1903, 3, 4]);
Expected := ExpectedRow.ToArray;
CUT := TMatrix.Create('89 1903 3\n18 3 1\n9 4 800');
Actual := CUT.column(1);
Actual := CUT.column(2);
CompareArrays(Expected, Actual);
end;

Expand All @@ -144,7 +145,7 @@ procedure TMatrixTest.extract_row_from_one_number_matrix;
ExpectedRow.AddRange([1]);
Expected := ExpectedRow.ToArray;
CUT := TMatrix.Create('1');
Actual := CUT.Row(0);
Actual := CUT.Row(1);
CompareArrays(Expected, Actual);
end;

Expand All @@ -157,7 +158,7 @@ procedure TMatrixTest.extract_row_where_numbers_have_different_widths;
ExpectedRow.AddRange([10, 20]);
Expected := ExpectedRow.ToArray;
CUT := TMatrix.Create('1 2\n10 20');
Actual := CUT.Row(1);
Actual := CUT.Row(2);
CompareArrays(Expected, Actual);
end;

Expand Down