Skip to content

Commit 3e5e78d

Browse files
committed
Add factorial.
1 parent a10009d commit 3e5e78d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/algorithms/string/permutations/__test__/permutateWithoutRepetitions.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import permutateWithoutRepetitions from '../permutateWithoutRepetitions';
2+
import factorial from '../../../math/factorial/factorial';
23

34
describe('permutateString', () => {
45
it('should permutate string', () => {
@@ -23,7 +24,7 @@ describe('permutateString', () => {
2324
]);
2425

2526
const permutations3 = permutateWithoutRepetitions('ABC');
26-
expect(permutations3.length).toBe(2 * 3);
27+
expect(permutations3.length).toBe(factorial(3));
2728
expect(permutations3).toEqual([
2829
'CBA',
2930
'BCA',
@@ -34,7 +35,7 @@ describe('permutateString', () => {
3435
]);
3536

3637
const permutations4 = permutateWithoutRepetitions('ABCD');
37-
expect(permutations4.length).toBe(2 * 3 * 4);
38+
expect(permutations4.length).toBe(factorial(4));
3839
expect(permutations4).toEqual([
3940
'DCBA',
4041
'CDBA',
@@ -63,6 +64,6 @@ describe('permutateString', () => {
6364
]);
6465

6566
const permutations5 = permutateWithoutRepetitions('ABCDEF');
66-
expect(permutations5.length).toBe(2 * 3 * 4 * 5 * 6);
67+
expect(permutations5.length).toBe(factorial(6));
6768
});
6869
});

0 commit comments

Comments
 (0)