On May 18, 4:15 pm, Phoe6 <[EMAIL PROTECTED]> wrote: > Hi All, > I would like to request a code and design review of one of my program. > n-puzzle.pyhttp://sarovar.org/snippet/detail.php?type=snippet&id=83 > Its a N-puzzle problem solver ( Wikipedia page > andhttp://norvig.com/ltd/test/n-puzzle.lisp > ) > > I have used OO Python for the above program and would like comments on > my approach as I am just starting with OOP. > > Thanks > Senthil
Nice job, this doesn't look like a beginner program at all. For feedback, here's a few nits: Instead of: if key + x in range(0, self.tsize): write: if 0 <= key + x < self.tsize: Instead of: mdist = mdist + jumps + steps write: mdist += jumps + steps Instead of: least_paths = [] for st in exp_sts: if self.manhattan_distance(st) == short_path: least_paths.append(st) write: least_paths = [st for st in exp_sts if self.manhattan_distance(st) == short_path] Instead of: short_path = mdists[0] if mdists.count(short_path) > 1: write: short_path = mdists[0] if short_path in mdists[1:]: Instead of: if node != 0: write: if node: Raymond -- http://mail.python.org/mailman/listinfo/python-list