Fix GeneratePermutations so that it actually returns the permutations instead of logging them + add Jest test.

This commit is contained in:
Eric Lavault
2021-10-09 14:29:44 +02:00
parent 4f4deac8d4
commit 09da5eef17
2 changed files with 31 additions and 13 deletions

View File

@ -0,0 +1,14 @@
import { permutations } from '../GeneratePermutations'
describe('Permutations', () => {
it('Permutations of [1, 2, 3]', () => {
expect(permutations([1, 2, 3])).toEqual([
[ 1, 2, 3 ],
[ 1, 3, 2 ],
[ 2, 1, 3 ],
[ 2, 3, 1 ],
[ 3, 1, 2 ],
[ 3, 2, 1 ]
])
})
})