Quantcast
Channel: How to improve performance of this code? - Stack Overflow
Browsing all 8 articles
Browse latest View live

Answer by Justin Peel for How to improve performance of this code?

My other answer is rather long, so I decided to list this as a separate answer. This problem is really better suited to doing a depth-first search. I made a depth-first search solution and it is much,...

View Article



Answer by Mike Dunlavey for How to improve performance of this code?

First let me tell you how to find the problem. Then I'll tell you where it is:I haven't even bothered to try to figure out your code. I just ran it and took 3 random-time stack samples. I did that by...

View Article

Answer by Justin Peel for How to improve performance of this code?

tkerwin is correct that you should be using a set for closedlist, which speeds things up a lot, but it is still kind of slow for 4 camels on each side. The next problem is that you are allowing a lot...

View Article

Answer by SingleNegationElimination for How to improve performance of this code?

Well, I can't really say quite where your algorithm is running astray, but I just went ahead and made my own. In the interest of doing the simplest thing that could possibly work, I used a bastardized...

View Article

Answer by Kabie for How to improve performance of this code?

The code below is using less than 1 second to solve this:from itertools import...

View Article


Answer by tkerwin for How to improve performance of this code?

I've been tripped up by this before too. The bottleneck here is actually if neighbor in closedlist.The in statement is so easy to use, you forget that it's linear search, and when you're doing linear...

View Article

Answer by aaronasterling for How to improve performance of this code?

Replacingclass node: def __init__(self, a, g, p): self.arrangement = a self.g = g self.parent = pwithnode = collections.namedtuple('node', 'arrangement, g, parent')dropped the times from around 340-600...

View Article

How to improve performance of this code?

Thanks to some help from people here, I was able to get my code for Tasmanian camels puzzle working. However, it is horribly slow (I think. I'm not sure because this is my first program in Python). The...

View Article

Browsing all 8 articles
Browse latest View live




Latest Images