mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-02-04 05:06:59 +08:00
Complying with JavaScript Standard Style (npx standard --fix).
This commit is contained in:
@@ -18,7 +18,7 @@ const swap = (arr, i, j) => {
|
||||
}
|
||||
|
||||
const permutations = arr => {
|
||||
let P = []
|
||||
const P = []
|
||||
const permute = (arr, low, high) => {
|
||||
if (low === high) {
|
||||
P.push([...arr])
|
||||
|
||||
@@ -3,12 +3,12 @@ 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 ]
|
||||
[1, 2, 3],
|
||||
[1, 3, 2],
|
||||
[2, 1, 3],
|
||||
[2, 3, 1],
|
||||
[3, 1, 2],
|
||||
[3, 2, 1]
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,21 +4,20 @@ describe('OpenKnightTour', () => {
|
||||
it('OpenKnightTour(5)', () => {
|
||||
const KT = new OpenKnightTour(5)
|
||||
expect(KT.board).toEqual([
|
||||
[ 0, 0, 0, 0, 0 ],
|
||||
[ 0, 0, 0, 0, 0 ],
|
||||
[ 0, 0, 0, 0, 0 ],
|
||||
[ 0, 0, 0, 0, 0 ],
|
||||
[ 0, 0, 0, 0, 0 ]
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0]
|
||||
])
|
||||
|
||||
KT.solve()
|
||||
expect(KT.board).toEqual([
|
||||
[ 19, 4, 15, 10, 25 ],
|
||||
[ 14, 9, 18, 5, 16 ],
|
||||
[ 1, 20, 3, 24, 11 ],
|
||||
[ 8, 13, 22, 17, 6 ],
|
||||
[ 21, 2, 7, 12, 23 ]
|
||||
[19, 4, 15, 10, 25],
|
||||
[14, 9, 18, 5, 16],
|
||||
[1, 20, 3, 24, 11],
|
||||
[8, 13, 22, 17, 6],
|
||||
[21, 2, 7, 12, 23]
|
||||
])
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user