-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaths.js
40 lines (39 loc) · 1.67 KB
/
paths.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const getKnightPath = (boardSize) => {
const paths = {
5: [
[0, 0], [2, 1], [0, 2], [1, 4], [3, 3],
[4, 1], [2, 0], [0, 1], [1, 3], [3, 4],
[4, 2], [3, 0], [1, 1], [0, 3], [2, 2],
[1, 0], [3, 1], [4, 3], [2, 4], [1, 2],
[0, 4], [2, 3], [4, 4], [3, 2], [4, 0]
],
6: [
[0, 0], [2, 1], [0, 2], [2, 3], [0, 4], [2, 5],
[4, 4], [5, 2], [4, 0], [3, 2], [1, 1], [0, 3],
[1, 5], [3, 4], [5, 5], [4, 3], [5, 1], [3, 0],
[4, 2], [5, 4], [3, 5], [1, 4], [3, 3], [1, 2],
[2, 0], [0, 1], [1, 3], [0, 5], [2, 4], [4, 5],
[5, 3], [4, 1], [2, 2], [1, 0], [3, 1], [5, 0]
],
7: [
[0, 0], [2, 1], [0, 2], [2, 3], [0, 4], [2, 5], [0, 6],
[1, 4], [3, 3], [1, 2], [3, 1], [1, 0], [2, 2], [0, 1],
[2, 0], [4, 1], [6, 0], [5, 2], [4, 0], [6, 1], [4, 2],
[5, 0], [6, 2], [4, 3], [2, 4], [1, 6], [3, 5], [5, 4],
[4, 6], [6, 5], [5, 3], [3, 2], [1, 3], [0, 5], [2, 6],
[3, 4], [1, 5], [0, 3], [1, 1], [3, 0], [5, 1], [6, 3],
[5, 5], [3, 6], [4, 4], [5, 6], [6, 4], [4, 5], [6, 6]
],
8: [
[0, 0], [2, 1], [4, 2], [6, 3], [7, 5], [6, 7], [4, 6], [2, 7],
[0, 6], [1, 4], [3, 5], [5, 6], [7, 7], [6, 5], [5, 7], [3, 6],
[1, 7], [0, 5], [2, 6], [4, 7], [5, 5], [7, 6], [6, 4], [4, 5],
[6, 6], [5, 4], [3, 3], [2, 5], [3, 7], [1, 6], [0, 4], [1, 2],
[2, 4], [0, 3], [1, 1], [3, 0], [2, 2], [1, 0], [0, 2], [2, 3],
[4, 4], [3, 2], [4, 0], [6, 1], [7, 3], [5, 2], [7, 1], [5, 0],
[3, 1], [4, 3], [5, 1], [7, 0], [6, 2], [7, 4], [5, 3], [7, 2],
[6, 0], [4, 1], [2, 0], [0, 1], [1, 3], [3, 4], [1, 5], [0, 7]
]
};
return paths[boardSize] || [];
};