Knight's tour Warndorff's algorithm problem

Robin Rytich robin.rytich at gmail.com
Tue Mar 9 20:57:47 EST 2010


Hi all

I'm having some troubles with writing Knight's tour
(http://en.wikipedia.org/wiki/Knight%27s_tour) solution in Python 3. I'm
using Warnsdorff's algorithm (http://en.wikipedia.org/wiki/Knight%
27s_tour#Algorithm) and I'm wondering why it doesn't work with boards of
certain sizes. I've written a solution and I like it but it does not
work correctly for 15x15, 26x26, 27x27 and 32x32 boards (don't know why;
checked from 5x5 to 40x40). So I'd be really glad if you tell me whether
I am too stupid for Python or for Discrete Math? In other words, did I
implemented Warnsdorff's algorithm in Python 3 correctly or maybe all my
troubles are because I haven't read tutorial with enough patience?

P.S. Warnsdorff's algorithm says that it's not really important which
square to choose between those which have equal amount of ways out. In
spite of that I tried to changed my program and added '=' to condition
at line 78. Results were quite surprising: now it works for 5x5,
6x6, ... 34x34 but not for 35x35!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: knights_tour.py
Type: text/x-python
Size: 3210 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20100310/7b3c8d97/attachment.py>


More information about the Python-list mailing list