Skip to content

Commit fde84ab

Browse files
committed
Update GeneratePermutations.test.js
Factorials are now explicit in the last set of tests.
1 parent e327fad commit fde84ab

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Backtracking/tests/GeneratePermutations.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ describe('Permutations', () => {
2626
})
2727

2828
it('Permutation counts across larger input arrays', () => {
29-
expect(permutations([1, 2, 3, 4, 5, 6])).toHaveLength(720)
30-
expect(permutations([1, 2, 3, 4, 5, 6, 7])).toHaveLength(5040)
29+
const factorial = (previousVal, currentVal) => previousVal * currentVal
30+
const input8 = [1, 2, 3, 4, 5, 6, 7, 8]
31+
const input9 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
32+
33+
expect(permutations(input8)).toHaveLength(input8.reduce(factorial, 1))
34+
expect(permutations(input9)).toHaveLength(input9.reduce(factorial, 1))
3135
})
3236
})

0 commit comments

Comments
 (0)