RFC - n-puzzle.py
Phoe6
orsenthil at gmail.com
Sat May 19 08:38:37 EDT 2007
On May 19, 2:23 pm, Raymond Hettinger <pyt... at rcn.com> wrote:
> On May 18, 4:15 pm, Phoe6 <orsent... at gmail.com> wrote:
> > 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
>
> Nice job, this doesn't look like a beginner program at all.
Thanks Raymond. :-)
> For feedback, here's a few nits:
Yes, I made changes in them all. Thanks for the list comprehension
pointer, I missed it.
>
> Instead of:
> short_path = mdists[0]
> if mdists.count(short_path) > 1:
> write:
> short_path = mdists[0]
> if short_path in mdists[1:]:
I would like to understand the difference between the two if
statements.
I had used count method, to signify the meaning that, if the least
distance occurs more then proceed with block.
How is 'in' with list[1:] an advantage? If it is.
> Instead of:
> if node != 0:
> write:
> if node:
Here again, I went by the meaning of non-zero value nodes and made
comparision with node != 0. Just in case, the n-states were
represented by '0', '1', '2', '3', I would have gone for node != '0'
sticking to the meaning. I think, I should aid it with a comment,
otherwise might get confused in the future.
Thanks a lot, Raymond. :-)
--
Senthil
http://uthcode.sarovar.org
More information about the Python-list
mailing list