Skip to content

Develop #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2025
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
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
"[csharp]": {
"editor.defaultFormatter": "ms-dotnettools.csharp"
},
"omnisharp.enableEditorConfigSupport": true,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[github-actions-workflow]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"omnisharp.enableEditorConfigSupport": true,
"snyk.advanced.additionalParameters": "--exclude=.trunk,coverage-report"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ private static List<int> getHourGlass(List<List<int>> arr, int positionX, int po

public static int hourglassSum(List<List<int>> arr)
{
int matrixSize = 0;

if (arr.Count > 0)
{
matrixSize = arr.Count;
}
int matrixSize = arr.Count;

int matrixStartIndex = 1;
int matrixEndIndex = matrixSize - 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,29 @@
[0, 0, 1, 2, 4, 0]
],
"expected": 19
},
{
"title": "Sample Test Case 1",
"input": [
[1, 1, 1, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0],
[0, 9, 2, -4, -4, 0],
[0, 0, 0, -2, 0, 0],
[0, 0, -1, -2, -4, 0]
],
"expected": 13
},
{
"title": "Sample Test Case 2",
"input": [
[-9, -9, -9, 1, 1, 1],
[0, -9, 0, 4, 3, 2],
[-9, -9, -9, 1, 2, 3],
[0, 0, 8, 6, 6, 0],
[0, 0, 0, -2, 0, 0],
[0, 0, 1, 2, 4, 0]
],
"expected": 28
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,16 @@ public void testHourglassSum()
Assert.AreEqual(test.expected, result);
}
}


[TestMethod]
public void testHourglassSumEdgeCases()
{
List<List<int>> input = [];
int expected = 0;
int result = TwoDArray.hourglassSum(input);

Assert.AreEqual(expected, result);
}
}

Loading