list comprehension syntax..?

Gregory Guthrie guthrie at mum.edu
Tue Aug 1 13:01:56 EDT 2006


Sorry for a simple question- but I don't understand how to parse this use of 
a list comprehension.

The "or" clauses are odd to me.

It also seems like it is being overly clever (?) in using a lc expression as 
a for loop to drive the recursion.

Thanks for any insight!
Gregory
-------------------------

#  http://markbyers.com/moinmoin/moin.cgi/ShortestSudokuSolver

def solve(board):
 i=board.find('0')      # find next open cell
 if i<0:                # done if none...
     print board; exit("Done")
 [ m in [(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)
          or board[j] for j in range(81) ]
     or solve(board[:i]+m+board[i+1:]) for m in'%d'%5**18 ] 



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----



More information about the Python-list mailing list