diff --git a/src/hackerrank/interview_preparation_kit/arrays/2d_array.js b/src/hackerrank/interview_preparation_kit/arrays/2d_array.js index bae6bb05..d6474676 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/2d_array.js +++ b/src/hackerrank/interview_preparation_kit/arrays/2d_array.js @@ -2,7 +2,7 @@ * @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/2d_array.md]] */ -export function gethourGlass(arr, positionX, positionY) { +function gethourGlass(arr, positionX, positionY) { const result = []; // top @@ -18,7 +18,7 @@ export function gethourGlass(arr, positionX, positionY) { return result; } -export function hourglassSum(arr) { +function hourglassSum(arr) { let matrixSize = 0; if (arr?.[0]) { diff --git a/src/hackerrank/interview_preparation_kit/arrays/2d_array.test.js b/src/hackerrank/interview_preparation_kit/arrays/2d_array.test.js index 2b67bd17..c15f0072 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/2d_array.test.js +++ b/src/hackerrank/interview_preparation_kit/arrays/2d_array.test.js @@ -1,15 +1,15 @@ import { describe, expect, it } from '@jest/globals'; import { logger as console } from '../../../logger.js'; -import { hourglassSum } from './2d_array.js'; +import twoDArray from './2d_array.js'; import TEST_CASES from './2d_array.testcases_test.json'; describe('arrays: 2d Array hourglassSum', () => { it('hourglassSum Test Cases', () => { - expect.assertions(1); + expect.assertions(3); TEST_CASES.forEach((test) => { - const answer = hourglassSum(test.input); + const answer = twoDArray.hourglassSum(test.input); console.debug( `gethourGlass(${test.input.toString()}) solution found: ${answer}` diff --git a/src/hackerrank/interview_preparation_kit/arrays/2d_array.testcases_test.json b/src/hackerrank/interview_preparation_kit/arrays/2d_array.testcases_test.json index f32bdef3..91ecbd7d 100644 --- a/src/hackerrank/interview_preparation_kit/arrays/2d_array.testcases_test.json +++ b/src/hackerrank/interview_preparation_kit/arrays/2d_array.testcases_test.json @@ -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 } ]