-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpermutations.test.js
32 lines (31 loc) · 1.04 KB
/
permutations.test.js
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
var { Permutations } = require('../dist/js-data-structs.cjs');
describe('Check permutations', () => {
it('should be able to generate all permutations of an array', () => {
expect(Permutations([1, 2, 3, 4])).toEqual([
['1', '2', '3', '4'],
['2', '1', '3', '4'],
['3', '1', '2', '4'],
['1', '3', '2', '4'],
['2', '3', '1', '4'],
['3', '2', '1', '4'],
['4', '2', '3', '1'],
['2', '4', '3', '1'],
['3', '4', '2', '1'],
['4', '3', '2', '1'],
['2', '3', '4', '1'],
['3', '2', '4', '1'],
['4', '1', '3', '2'],
['1', '4', '3', '2'],
['3', '4', '1', '2'],
['4', '3', '1', '2'],
['1', '3', '4', '2'],
['3', '1', '4', '2'],
['4', '1', '2', '3'],
['1', '4', '2', '3'],
['2', '4', '1', '3'],
['4', '2', '1', '3'],
['1', '2', '4', '3'],
['2', '1', '4', '3']
]);
});
});