-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateMatrix.test.ts
More file actions
59 lines (56 loc) · 1.62 KB
/
Copy pathupdateMatrix.test.ts
File metadata and controls
59 lines (56 loc) · 1.62 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { updateMatrix } from './updateMatrix'
describe('542. 01 矩阵', () => {
test('mat = [[0,0,0],[0,1,0],[0,0,0]]', () => {
expect(
updateMatrix([
[0, 0, 0],
[0, 1, 0],
[0, 0, 0],
]),
).toEqual([
[0, 0, 0],
[0, 1, 0],
[0, 0, 0],
])
}, 300)
test('mat = [[0,0,0],[0,1,0],[1,1,1]]', () => {
expect(
updateMatrix([
[0, 0, 0],
[0, 1, 0],
[1, 1, 1],
]),
).toEqual([
[0, 0, 0],
[0, 1, 0],
[1, 2, 1],
])
}, 300)
test('mat = [[1,0,1,1,0,0,1,0,0,1],[0,1,1,0,1,0,1,0,1,1],[0,0,1,0,1,0,0,1,0,0],[1,0,1,0,1,1,1,1,1,1],[0,1,0,1,1,0,0,0,0,1],[0,0,1,0,1,1,1,0,1,0],[0,1,0,1,0,1,0,0,1,1],[1,0,0,0,1,1,1,1,0,1],[1,1,1,1,1,1,1,0,1,0],[1,1,1,1,0,1,0,0,1,1]]', () => {
expect(
updateMatrix([
[1, 0, 1, 1, 0, 0, 1, 0, 0, 1],
[0, 1, 1, 0, 1, 0, 1, 0, 1, 1],
[0, 0, 1, 0, 1, 0, 0, 1, 0, 0],
[1, 0, 1, 0, 1, 1, 1, 1, 1, 1],
[0, 1, 0, 1, 1, 0, 0, 0, 0, 1],
[0, 0, 1, 0, 1, 1, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0, 0, 1, 1],
[1, 0, 0, 0, 1, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 0, 1, 0],
[1, 1, 1, 1, 0, 1, 0, 0, 1, 1],
]),
).toEqual([
[1, 0, 1, 1, 0, 0, 1, 0, 0, 1],
[0, 1, 1, 0, 1, 0, 1, 0, 1, 1],
[0, 0, 1, 0, 1, 0, 0, 1, 0, 0],
[1, 0, 1, 0, 1, 1, 1, 1, 1, 1],
[0, 1, 0, 1, 1, 0, 0, 0, 0, 1],
[0, 0, 1, 0, 1, 1, 1, 0, 1, 0],
[0, 1, 0, 1, 0, 1, 0, 0, 1, 1],
[1, 0, 0, 0, 1, 2, 1, 1, 0, 1],
[2, 1, 1, 1, 1, 2, 1, 0, 1, 0],
[3, 2, 2, 1, 0, 1, 0, 0, 1, 1],
])
}, 300)
})