A knight's tour is a sequence of moves of a knight on a chessboard.
Questions tagged [knights-tour]
223 questions
0
votes
1 answer
Solving 8x8 Recursive Knight Tour in Python
Problem Explanation
I wanted to create a Knight's Tour in an 8x8 board and only used recursion to implement the code thus far.
The knight tour for an 8x8 board has around 19 quadrillion moves.
src =…

Santosh Kutti
- 11
- 1
0
votes
1 answer
Knight's Tour in Python - Getting Path from Predecessors
I'm trying to adapt a Depth-First Search algorithm in Python to solve the Knight's Tour puzzle. I think I've nearly succeeded, by producing a dictionary of predecessors for all the visited squares.
However, I'm stuck on how to find the autual path…

Robin Andrews
- 3,514
- 11
- 43
- 111
0
votes
1 answer
Java solving Knights tour takes very long
Hey so i gotta code an algorithm for the Springerproblem (https://upload.wikimedia.org/wikipedia/commons/8/86/Knight%27s_tour.svg)
My code is currently endlessly running at a field of 6x6
We got a Junit class to test it. a field of 3x3 with the…

rxbxi
- 15
- 5
0
votes
1 answer
I am working on knight tour problem using backtracking but i am not getting the desired result
I tried knight Tour problem, although the code looks correct only still I am not getting the correct answer always it is returning -1 i.e no solution exists.
I have defined few functions first one is select that returns the pair for next move…

Hritik Sharma
- 69
- 1
- 5
0
votes
1 answer
How to fix the error "Bad Operand Types for Binary Operator '>=' first type: int[] second type int"
**The error is with this line: **
if ((board[r + vertical[movenumber]]) <= 8 && board[r + vertical[movenumber]] >= 1)
**Whole method if needed: **
public void tour()
{
int starter = 1;
int start1 = (int)(Math.random() * 8 - 1) + 1;
…

Kush
- 3
- 1
0
votes
0 answers
Knight's Tour, DFS solution slow
I've been working on analysing memory and timing profile of Knight's Tour in Python with blind depth-first search, and wrote a simple program to be able to generate solutions, or so I thought.
My task is to choose 5 initial starting points on the…

Jack Avante
- 1,405
- 1
- 15
- 32
0
votes
2 answers
Is there any algorithm to find overlapping edges in a graph?
I'm solving extended version of knight tour problem, in which program has to return maximum number of cells through which knight can come back to initial position without overlapping its path.
I'm using backtracking approach but got stuck in…

NeerajSahani
- 121
- 1
- 4
0
votes
0 answers
Solving knights tour using warndorffs heurisitic for the first 32 moves, and brute force backtracking using a stack for the next
This is my main function for running the knights tour, the idea is that while count is 32 itll pick a point using the heurisitic and while its greater than 32 itll randomly pick a point, and if that point works ill make a knight object, pass it the…

Jacob Fernandez
- 11
- 2
0
votes
1 answer
Stuck in an infinite loop (Knight's Tour Problem)
The Knight's Tour Problem:
The knight is placed on the first block of an empty board and, moving according to the rules of chess, must visit each square exactly once. Print the path such that it covers all the blocks.
Could not understand why the…
user9231528
0
votes
1 answer
Knight' tour using Warnsdorff's rule gives wrong output with odd sizes mostly
I wrote a code to solve the knight's tour problem, the problem is that sometimes it gets the wrong output.
In particular, very frequently with odd sizes of the board: For example starting at position [0,1] and with a board 5X5 it gives me:
[[0, 1],…

Tortar
- 625
- 5
- 15
0
votes
2 answers
This code seems to never reach the solution even though it doesn't go into an infinite loop
I wanted to solve the Knight's Tour and came up with the following program. It never gives a solution (even given 2 hours of time) even though it doesn't seem to be getting into an infinite loop anywhere.
I tried it with a 4x4 board (with one space…
0
votes
0 answers
Why Knight Tour Problem is taking so much time in this code?
I wrote down the code for knight tour problem, I couldn't figure out what is the actual issue with the solution, it's running fine upto n=6, but after that it is taking a long time to run. It's showing correct output but taking a really long time as…

A.S.
- 1
- 1
- 2
0
votes
1 answer
knight tour iteration dead end
I am trying to implement knight tour using iteration method. I have already wrote a program using recursion and its working fine, now instead of recursion I am using iteration method with stack to implement knight tour, I have wrote the below…

Abdul Rahman
- 87
- 1
- 2
- 9
0
votes
1 answer
n length knight moves combinations on keypad
find n length knight move combinations on keypad numbers from 0 - 9
unable to resolve this, getting either infinite loop or the total number of expected combinations is incorrect. Tried to dynamic programming, should it be counting possible…

cald00dvin
- 9
- 2
0
votes
1 answer
Solving knight's tour problem on a huge board?
I have found this code that solves the Knight's Tour problem.
If I, for example, want to solve a board of size 800x800 I get the following error:
Exception thrown at 0x00007FF6345D3778 in test.exe: 0xC00000FD: Stack overflow (parameters:…

Hamza Alrawi
- 33
- 5