Complying with JavaScript Standard Style (npx standard --fix).

This commit is contained in:
Eric Lavault
2021-10-11 15:49:24 +02:00
parent 87a3da7e37
commit df4a783b06
22 changed files with 28 additions and 42 deletions

View File

@@ -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])

View File

@@ -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]
])
})
})

View File

@@ -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]
])
})
})