Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Knight's tour in perl ithreads

Reply
Thread Tools

Knight's tour in perl ithreads

 
 
Walter Roberson
Guest
Posts: n/a
 
      02-02-2004
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 |
-+----+----+----+----+----+

--
Rump-Titty-Titty-Tum-TAH-Tee -- Fritz Lieber
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tour in Nepal, Nepal Tour, Nepal Tour Package tourinnepal Python 0 01-30-2010 09:53 AM
ithreads + signals on modern Unices Thomas Jahns Perl Misc 4 02-21-2005 02:25 PM
Qustion about ithreads join Taewoon Kwon Perl 1 09-15-2004 05:55 AM
ithreads at runtime? Walter Roberson Perl Misc 3 02-04-2004 04:15 AM
Is the ithreads implementation safe? David Morel Perl Misc 0 09-13-2003 06:38 PM



Advertisments