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
Replacing
class node:
def __init__(self, a, g, p):
self.arrangement = a
self.g = g
self.parent = p
with
node = collections.namedtuple('node', 'arrangement, g, parent')
dropped the times from around 340-600 msecs to 11.4 1.891 msecs on the input [fCamel, fCamel, gap, bCamel, bCamel]
. It yielded the same output.
This obviously won't help with any algorithmic problems but as far as micro-optimizations go, it isn't bad.
1 I had the wrong input. There was an extra fCamel
that was making it run slower.