-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2d-array-ds.spec.ts
More file actions
32 lines (29 loc) · 842 Bytes
/
Copy path2d-array-ds.spec.ts
File metadata and controls
32 lines (29 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { hourglassSum } from './2d-array-ds'
describe('2dArrayDS', () => {
it('should return the largest (maximum) hourglass sum found in arr', () => {
expect(
hourglassSum([
[1, 1, 1, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0],
[0, 0, 2, 4, 4, 0],
[0, 0, 0, 2, 0, 0],
[0, 0, 1, 2, 4, 0],
])
).toBe(19)
expect(
hourglassSum([
[-1, -1, 0, -9, -2, -2],
[-2, -1, -6, -8, -2, -5],
[-1, -1, -1, -2, -3, -4],
[-1, -9, -2, -4, -4, -5],
[-7, -3, -3, -2, -9, -9],
[-1, -3, -1, -2, -4, -5],
])
).toBe(-6)
})
it('should return infinity if the hourglass sum is negative', () => {
expect(hourglassSum([[-1, -1, 0, -9, -2, -2]])).toBe(-Infinity)
expect(hourglassSum([[]])).toBe(-Infinity)
})
})