8 queen/game of life

Tim Rowe digitig at cix.co.uk
Thu Jun 15 15:28:00 EDT 2000


In article <39485C09.306BF3DC at videon.home.com>, krussell4 at videon.home.com 
(Kevin Russell) wrote:

> root wrote:
> 
> >    the matrix is fixed, which is not good. my solution use dictionary 
> > (i
> >    know this is not the right way). the key is a tuple of the matrix
> >    indices. the value is '0'. then base on game of life rule, update 
> > the
> >    dictionary and print for next generation.
> >
> >            m={}
> >            m[(0,0)] = 0, m[(0,1)] = 1,....
> 
> If it works, then it IS the right way.  After all, there's more than one
> way to... oops, sorry, wrong newsgroup.
> 
> As Trent Mick has pointed out, there's NumPy for doing serious
> matrix manipulation.  But the demands of the Game of Life and the
> 8-Queens problem are minimal enough that a list-of-lists solution
> or your dictionary solution are perfectly adequate.

Hmm. Game of Life is often considered computationally expensive. Though 
mainly because the sort of things people do tend to expand to fill the 
cycles available...



More information about the Python-list mailing list