Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tests: improve for GeneratePermutations#1263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
raklaptudirm merged 13 commits intoTheAlgorithms:masterfromkho-kho-kho:master
Nov 13, 2022
Merged
Changes fromall commits
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
ed5db20
Bugfix AVLTree comparator
kho-kho-khoAug 15, 2022
8ebb542
Merge branch 'TheAlgorithms:master' into master
kho-kho-khoSep 12, 2022
2ea10b0
100% jest code coverage
kho-kho-khoSep 13, 2022
5f3b57c
standard style fix
kho-kho-khoSep 13, 2022
8d50f72
Merge branch 'TheAlgorithms:master' into master
kho-kho-khoSep 17, 2022
1ab0a82
Iterative & in-place BFS
kho-kho-khoSep 17, 2022
e0d683e
Update BreadthFirstTreeTraversal.js
kho-kho-khoSep 18, 2022
20c54f3
refactor out traversal member var
kho-kho-khoSep 25, 2022
7a55d68
Merge branch 'master' of https://github.com/kho-kho-kho/JavaScript
kho-kho-khoSep 25, 2022
e8af126
Merge branch 'TheAlgorithms:master' into master
kho-kho-khoNov 10, 2022
e327fad
Update GeneratePermutations.test.js
kho-kho-khoNov 10, 2022
fde84ab
Update GeneratePermutations.test.js
kho-kho-khoNov 10, 2022
542b0ca
Update GeneratePermutations.test.js
kho-kho-khoNov 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletionsBacktracking/tests/GeneratePermutations.test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
import { factorial } from '../../Recursive/Factorial'
import { permutations } from '../GeneratePermutations'

describe('Permutations', () => {
it('Permutations of [a]', () => {
const perms = permutations(['a'])
expect(perms).toHaveLength(factorial(1))
expect(perms).toContainEqual(['a'])
})

it('Permutations of [true, false]', () => {
const perms = permutations([true, false])
expect(perms).toHaveLength(factorial(2))
expect(perms).toContainEqual([true, false])
expect(perms).toContainEqual([false, true])
})

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]
])
const perms = permutations([1, 2, 3])
expect(perms).toHaveLength(factorial(3))
expect(perms).toContainEqual([1, 2, 3])
expect(perms).toContainEqual([1, 3, 2])
expect(perms).toContainEqual([2, 1, 3])
expect(perms).toContainEqual([2, 3, 1])
expect(perms).toContainEqual([3, 1, 2])
expect(perms).toContainEqual([3, 2, 1])
})

it('Permutation counts across larger input arrays', () => {
expect(permutations([1, 2, 3, 4, 5, 6, 7, 8])).toHaveLength(factorial(8))
expect(permutations([1, 2, 3, 4, 5, 6, 7, 8, 9])).toHaveLength(factorial(9))
})
})

[8]ページ先頭

©2009-2025 Movatter.jp