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
4 changes: 2 additions & 2 deletions src/hackerrank/interview_preparation_kit/arrays/2d_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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}`
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
}
]