Knight's tour in perl ithreads

  • Thread starter Walter Roberson
  • Start date
W

Walter Roberson

For my amusement / edification, I implimented the generalized
chess "Knight's Tour" problem in perl ithreads with message
passing.

The current version is certainly not the most efficient possible,
and it probably has an off-by-one error in what it thinks of
as a complete solution (I haven't run it long enough to -produce-
a complete solution... it's not the fastest program in the world.)
It's also not intended as a paragon of clean perl coding.

If someone happens to be interested in amusing themselves with
it, or interested in examining an example of threads and message
passing at work, then send me email and I'll send you the source.

[The source isn't terribly long, but I don't have active WWW
pages at the moment or I'd just post a link to it.]


Here's some sample output on the 5x5 board (which isn't solvable btw):

Found partial solution length 23. It's 0 7 4 13 24 17 10 1 8 19 22 15 6 3 14 23 16 5 2 9 18 11 0
:1 :2 :3 :4 :5 :
-+----+----+----+----+----+
1 |23 |8 |19 |14 |3 |
-+----+----+----+----+----+
2 |18 |13 |2 |9 |20 |
-+----+----+----+----+----+
3 |7 |22 |0 |4 |15 |
-+----+----+----+----+----+
4 |12 |17 |6 |21 |10 |
-+----+----+----+----+----+
5 |0 |0 |11 |16 |5 |
-+----+----+----+----+----+
Found partial solution length 23. It's 0 11 20 17 24 13 6 15 22 19 8 1 10 21 18 9 2 5 16 23 14 7 4
:1 :2 :3 :4 :5 :
-+----+----+----+----+----+
1 |1 |12 |17 |0 |23 |
-+----+----+----+----+----+
2 |18 |7 |22 |11 |16 |
-+----+----+----+----+----+
3 |13 |2 |0 |6 |21 |
-+----+----+----+----+----+
4 |8 |19 |4 |15 |10 |
-+----+----+----+----+----+
5 |3 |14 |9 |20 |5 |
-+----+----+----+----+----+
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top