[Tutor] checking diagonals on a chessboard

2006-04-13 Thread Matthew Singletary
first, A disclaimer:
This isn't directly homework but is related to an assignment of mine
 
I'm building a genetic algorithm to solve the queen placement problem, the complicated stuff I can do on my own, but I'm not getting one part.  
suppose the queen is on a square, I can check that it is in the same row or same col but the diagonals, are less straight-forward.
I know I could solve this by just smashing away at it, but I was wondering if anyone could suggest some tips on directions to work
 
I'm NOT looking for any answers, just some tips to an _elegant_ method to solve this.
 
The reason I started teaching myself python was it seemed a little more concise, and it seems there should be an elegant way to do this but I guess I'm not used to thinking the pythonic way
 
thanks for any help
matt
 
 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] checking diagonals on a chessboard

2006-04-13 Thread Matthew Singletary
Thanks for the input from everyone,I had been working with a flat array and checking the horizontals and verticals with slices and mod math but I think the tuple approach would be pretty easy to change to use.
I can't ever recall being interested in a test from a test suite but my interest is piqued.  I get to spend this weekend working on this and some simulated annealling so I will get to polish my python skills some more.
Thanks again,matt
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor