Re: Knight's tour Warndorff's algorithm problem

2010-03-10 Thread Robin Rytich
On Wed, 2010-03-10 at 02:37 -0300, Gabriel Genellina wrote: Warnsdorff's algorithm is heuristic; it works most of the time, but in some cases leads to a dead end and you have to backtrack and try another alternative. The starting square is important; if you start at 1,1 (instead of 0,0)

Re: Knight's tour Warndorff's algorithm problem

2010-03-10 Thread Terry Reedy
On 3/10/2010 12:37 AM, Gabriel Genellina wrote: if (next != 0): (self.y, self.x) = (next.y, next.x) In Python3, next is a builtin function. Choose a different name, at least in public code ;=). -- http://mail.python.org/mailman/listinfo/python-list

Re: Knight's tour Warndorff's algorithm problem

2010-03-10 Thread Lawrence D'Oliveiro
In message mailman.527.1268199449.23598.python-l...@python.org, Gabriel Genellina wrote: Warnsdorff's algorithm is heuristic ... Then it shouldn’t be called an “algorithm”. -- http://mail.python.org/mailman/listinfo/python-list

Re: Knight's tour Warndorff's algorithm problem

2010-03-10 Thread Robert Kern
On 2010-03-10 15:49 PM, Lawrence D'Oliveiro wrote: In messagemailman.527.1268199449.23598.python-l...@python.org, Gabriel Genellina wrote: Warnsdorff's algorithm is heuristic ... Then it shouldn’t be called an “algorithm”. There are lots of algorithms that use heuristics or are heuristics.

Re: Knight's tour Warndorff's algorithm problem

2010-03-10 Thread Grant Edwards
On 2010-03-10, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message mailman.527.1268199449.23598.python-l...@python.org, Gabriel Genellina wrote: Warnsdorff's algorithm is heuristic ... Then it shouldn???t be called an ???algorithm???. Why? An algorithm is just a

Re: Knight's tour Warndorff's algorithm problem

2010-03-10 Thread Terry Reedy
On 3/10/2010 4:49 PM, Lawrence D'Oliveiro wrote: In messagemailman.527.1268199449.23598.python-l...@python.org, Gabriel Genellina wrote: Warnsdorff's algorithm is heuristic ... Then it shouldn’t be called an “algorithm”. Heuristic algorithms correctly compute some function, just not the

Knight's tour Warndorff's algorithm problem

2010-03-09 Thread Robin Rytich
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

Knight's tour Warndorff's algorithm problem

2010-03-09 Thread Gabriel Genellina
El 9 mar, 22:57, Robin Rytich escribió: 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

An algorithm problem

2006-05-31 Thread Bo Yang
Hi , I have writen a python program to slove a problem described as below: (Forgive my poor English !) Put the 2^n 0 or 1 to form a ring , and we can select any continuous n ones from the ring to constitute a binary number . And obviously we can get 2^n selections , so the question is : Given a

Re: An algorithm problem

2006-05-31 Thread Sybren Stuvel
Bo Yang enlightened us with: I have writen a python program to slove a problem described as below: Please post again, but then leaving indentation intact, since this is unreadable. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for

Re: An algorithm problem

2006-05-31 Thread John Machin
On 31/05/2006 4:58 PM, Bo Yang wrote: Hi , I have writen a python program to slove a problem described as below: (Forgive my poor English !) Put the 2^n 0 or 1 to form a ring , Sorry, I can't understand that. It would be very helpful if you wrote out (for example, when n == 3) what the

Re: An algorithm problem

2006-05-31 Thread Bo Yang
I am sorry , and thanks for your friendliness . I have change my source code for more meaningful variable name and more comments follow the instructions John has writen . I think that is useful for you to look my code . And this time I put the code in the attachment . Indeed , I write that in

Re: An algorithm problem

2006-05-31 Thread Bo Yang
I am sorry , and thanks for your friendliness . I have change my source code for more meaningful variable name and more comments follow the instructions John has writen . I think that is useful for you to look my code . And this time I put the code in the attachment . Indeed , I write that in

Re: An algorithm problem

2006-05-31 Thread Maric Michaud
Le Mercredi 31 Mai 2006 08:58, Bo Yang a écrit : RuntimeError: maximum recursion depth exceeded It's tied to the recursive call to the ring function, python raises a limit to recursive calls to avoid infinite recursion. You can just adjust the limit using these two lines when you call the

Re: An algorithm problem

2006-05-31 Thread John Machin
On 31/05/2006 7:20 PM, Bo Yang wrote: I am sorry , and thanks for your friendliness . I have change my source code for more meaningful variable name and more comments follow the instructions John has writen . I think that is useful for you to look my code . And this time I put the code in