diff --git a/docs/hackerrank/warmup/interview_preparation_kit/2d_array.md b/docs/hackerrank/interview_preparation_kit/2d_array.md similarity index 100% rename from docs/hackerrank/warmup/interview_preparation_kit/2d_array.md rename to docs/hackerrank/interview_preparation_kit/2d_array.md diff --git a/exercises/hackerrank/interview_preparation_kit/arrays/2d_array.go b/exercises/hackerrank/interview_preparation_kit/arrays/2d_array.go index 3ea4260..3c0c5b3 100644 --- a/exercises/hackerrank/interview_preparation_kit/arrays/2d_array.go +++ b/exercises/hackerrank/interview_preparation_kit/arrays/2d_array.go @@ -1,5 +1,5 @@ /** - * @link Problem definition [[docs/hackerrank/warmup/interview_preparation_kit/2d_array.md]] + * @link Problem definition [[docs/hackerrank/interview_preparation_kit/2d_array.md]] */ package hackerrank @@ -48,3 +48,7 @@ func hourglassSum(arr [][]int32) int32 { return maxHourglassSum } + +func HourglassSum(arr [][]int32) int32 { + return hourglassSum(arr) +} diff --git a/exercises/hackerrank/interview_preparation_kit/arrays/2d_array_test.go b/exercises/hackerrank/interview_preparation_kit/arrays/2d_array_test.go index d87d6a2..dcebbe4 100644 --- a/exercises/hackerrank/interview_preparation_kit/arrays/2d_array_test.go +++ b/exercises/hackerrank/interview_preparation_kit/arrays/2d_array_test.go @@ -9,34 +9,34 @@ import ( "gon.cl/algorithms/utils" ) -type TestCase struct { +type TwoDArrayTestCase struct { Input [][]int32 `json:"input"` Expected int32 `json:"expected"` } -var testCases []TestCase +var TwoDArrayTestCases []TwoDArrayTestCase // You can use testing.T, if you want to test the code without benchmarking -func setupSuite(t testing.TB) { +func twoDArraySetupSuite(t testing.TB) { wd, _ := os.Getwd() filepath := wd + "/2d_array.testcases.json" t.Log("Setup test cases from JSON: ", filepath) - var _, err = utils.LoadJSON(filepath, &testCases) + var _, err = utils.LoadJSON(filepath, &TwoDArrayTestCases) if err != nil { t.Log(err) } } -func Test2DArray(t *testing.T) { +func TestTwoDArray(t *testing.T) { - setupSuite(t) + twoDArraySetupSuite(t) - for _, tt := range testCases { + for _, tt := range TwoDArrayTestCases { testname := fmt.Sprintf("hourglassSum(%v) => %v \n", tt.Input, tt.Expected) t.Run(testname, func(t *testing.T) { - ans := hourglassSum(tt.Input) + ans := HourglassSum(tt.Input) assert.Equal(t, tt.Expected, ans) })