Skip to content

Commit 7e3c9f7

Browse files
authored
Merge pull request #279 from sir-gon/develop
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Array: 2D Array -…
2 parents 97861c1 + 0444738 commit 7e3c9f7

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed
File renamed without changes.

exercises/hackerrank/interview_preparation_kit/arrays/2d_array.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @link Problem definition [[docs/hackerrank/warmup/interview_preparation_kit/2d_array.md]]
2+
* @link Problem definition [[docs/hackerrank/interview_preparation_kit/2d_array.md]]
33
*/
44

55
package hackerrank
@@ -48,3 +48,7 @@ func hourglassSum(arr [][]int32) int32 {
4848

4949
return maxHourglassSum
5050
}
51+
52+
func HourglassSum(arr [][]int32) int32 {
53+
return hourglassSum(arr)
54+
}

exercises/hackerrank/interview_preparation_kit/arrays/2d_array_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@ import (
99
"gon.cl/algorithms/utils"
1010
)
1111

12-
type TestCase struct {
12+
type TwoDArrayTestCase struct {
1313
Input [][]int32 `json:"input"`
1414
Expected int32 `json:"expected"`
1515
}
1616

17-
var testCases []TestCase
17+
var TwoDArrayTestCases []TwoDArrayTestCase
1818

1919
// You can use testing.T, if you want to test the code without benchmarking
20-
func setupSuite(t testing.TB) {
20+
func twoDArraySetupSuite(t testing.TB) {
2121
wd, _ := os.Getwd()
2222
filepath := wd + "/2d_array.testcases.json"
2323
t.Log("Setup test cases from JSON: ", filepath)
2424

25-
var _, err = utils.LoadJSON(filepath, &testCases)
25+
var _, err = utils.LoadJSON(filepath, &TwoDArrayTestCases)
2626
if err != nil {
2727
t.Log(err)
2828
}
2929
}
3030

31-
func Test2DArray(t *testing.T) {
31+
func TestTwoDArray(t *testing.T) {
3232

33-
setupSuite(t)
33+
twoDArraySetupSuite(t)
3434

35-
for _, tt := range testCases {
35+
for _, tt := range TwoDArrayTestCases {
3636
testname := fmt.Sprintf("hourglassSum(%v) => %v \n", tt.Input, tt.Expected)
3737
t.Run(testname, func(t *testing.T) {
3838

39-
ans := hourglassSum(tt.Input)
39+
ans := HourglassSum(tt.Input)
4040
assert.Equal(t, tt.Expected, ans)
4141
})
4242

0 commit comments

Comments
 (0)