Here is the Knight’s tour algorithm implemented in Python. This is a very basic Brute Force algorithm – with no Algorithmic Optimization applied.

Solved it in 2 evenings about 4 hours of thinking and coding and some debugging.

**Command Line**

It takes 3 parameters

1st param – integer – size of the Grid ( always assumed it is a Square board )

2nd param – integer – starting location of the knight the x location

3rd param – integer – starting location of the knight the y location

( x, y ) start from 1 and the top left square is x = 1 and y = 2

The results are either

– No tour found

OR

an array of 2 Tuples ( x, y ) coordinates – which describe the Knight path move

from the starting location as specified in the input params

**Code**

https://github.com/palsumitpal/sumitpython/blob/master/KnightTourAgain.py

### Like this:

Like Loading...

*Related*