diff --git a/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/knights-tour.md b/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/knights-tour.md index c7a4b0693de..78de8ba6fd2 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/knights-tour.md +++ b/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/knights-tour.md @@ -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++; }