fix(curriculum): external knight's tour link in CIP (#46289)

* fix(curriculum): external knight's tour link in CIP

* Refacter the parameters
pull/46304/head
Muhammed Mustafa 2022-06-02 20:03:03 +02:00 committed by GitHub
parent 1d94a06c3f
commit 2e879b5dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -8,11 +8,11 @@ dashedName: knights-tour
# --description--
[Knight's Tour](https://en.wikipedia.org/wiki/Knight%27s_tour) Problem: You have an empty `w` \* `h` chessboard, but for a single knight on some square. The knight must perform a sequence of legal moves that result in the knight visiting every square on the chessboard exactly once. Note that it is *not* a requirement that the tour be "closed"; that is, the knight need not end within a single move of its start position.
Knight's Tour Problem: You have an empty `width` \* `height` chessboard, but for a single knight on some square. The knight must perform a sequence of legal moves that result in the knight visiting every square on the chessboard exactly once. Note that it is *not* a requirement that the tour be "closed"; that is, the knight need not end within a single move of its start position.
# --instructions--
Write a function that takes `w` and `h` as parameters and returns the number of initial positions from where it is possible to achieve the task stated above.
Write a function that takes `width` and `height` as parameters and returns the number of initial positions from where it is possible to achieve the task stated above.
# --hints--
@ -63,7 +63,7 @@ assert.equal(knightTour(8, 6), 48);
## --seed-contents--
```js
function knightTour(w, h) {
function knightTour(width, height) {
}
```
@ -71,7 +71,7 @@ function knightTour(w, h) {
# --solutions--
```js
function knightTour(w, h) {
function knightTour(width, height) {
function createBoards(rows, columns) {
const board = [];
const visited = [];
@ -210,11 +210,11 @@ function knightTour(w, h) {
[1, -2]
];
const [baseBoard, baseVisited] = createBoards(h, w);
const [baseBoard, baseVisited] = createBoards(height, width);
fillAllowedMovesCounts(baseBoard);
let solvedCount = 0;
for (let row = 0; row < h; row++) {
for (let column = 0; column < w; column++) {
for (let row = 0; row < height; row++) {
for (let column = 0; column < width; column++) {
if (solveStart(baseBoard, baseVisited, row, column)) {
solvedCount++;
}