Skip to content

Commit a34e66d

Browse files
authored
Merge pull request #636 from sir-gon/feature/2d_array
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Array: 2D Array -…
2 parents 6627018 + 6a26d57 commit a34e66d

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/hackerrank/interview_preparation_kit/arrays/2d_array.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/2d_array.md]]
33
*/
44

5-
export function gethourGlass(arr, positionX, positionY) {
5+
function gethourGlass(arr, positionX, positionY) {
66
const result = [];
77

88
// top
@@ -18,7 +18,7 @@ export function gethourGlass(arr, positionX, positionY) {
1818
return result;
1919
}
2020

21-
export function hourglassSum(arr) {
21+
function hourglassSum(arr) {
2222
let matrixSize = 0;
2323

2424
if (arr?.[0]) {

src/hackerrank/interview_preparation_kit/arrays/2d_array.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { describe, expect, it } from '@jest/globals';
22
import { logger as console } from '../../../logger.js';
33

4-
import { hourglassSum } from './2d_array.js';
4+
import twoDArray from './2d_array.js';
55
import TEST_CASES from './2d_array.testcases_test.json';
66

77
describe('arrays: 2d Array hourglassSum', () => {
88
it('hourglassSum Test Cases', () => {
9-
expect.assertions(1);
9+
expect.assertions(3);
1010

1111
TEST_CASES.forEach((test) => {
12-
const answer = hourglassSum(test.input);
12+
const answer = twoDArray.hourglassSum(test.input);
1313

1414
console.debug(
1515
`gethourGlass(${test.input.toString()}) solution found: ${answer}`

src/hackerrank/interview_preparation_kit/arrays/2d_array.testcases_test.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,29 @@
1010
[0, 0, 1, 2, 4, 0]
1111
],
1212
"expected": 19
13+
},
14+
{
15+
"title": "Sample Test Case 1",
16+
"input": [
17+
[1, 1, 1, 0, 0, 0],
18+
[0, 1, 0, 0, 0, 0],
19+
[1, 1, 1, 0, 0, 0],
20+
[0, 9, 2, -4, -4, 0],
21+
[0, 0, 0, -2, 0, 0],
22+
[0, 0, -1, -2, -4, 0]
23+
],
24+
"expected": 13
25+
},
26+
{
27+
"title": "Sample Test Case 2",
28+
"input": [
29+
[-9, -9, -9, 1, 1, 1],
30+
[0, -9, 0, 4, 3, 2],
31+
[-9, -9, -9, 1, 2, 3],
32+
[0, 0, 8, 6, 6, 0],
33+
[0, 0, 0, -2, 0, 0],
34+
[0, 0, 1, 2, 4, 0]
35+
],
36+
"expected": 28
1337
}
1438
]

0 commit comments

Comments
 (0)