<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
'Having trouble' is too vague to figure out. However, I would delete this: > def getEmptySlot(self): > i = 0 > j = 0 > while i <= self.dim-1: > while j <= self.dim-1: > if self.elements[j][i] == -1: > return [j, i] > j = j+1 > j = 0 > i = i + 1 and maintain an .empty attribute, which is trivially updated in > def swapElements(self, fromx, fromy, tox, toy): > dummy = self.elements[toy][tox] > > self.elements[toy][tox] = self.elements[fromy][fromx] > self.elements[fromy][fromx] = dummy as (fromy,fromx). Note that there is no need to pass tox, toy to this routine. Indeed, I would include the last two lines in your move routine. Since dummy is always the same object, I would also just keep it as self._dummy instead of looking it up each time. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list