def attacks(pos):
 row = filter((lambda r: (pos in r)), posrows)
 col = filter((lambda c: (pos in c)), poscols)
 dia = filter((lambda d: (pos in d)), posdiag)
 gai = filter((lambda g: (pos in g)), posgaid)
 assert (len(row) == len(col) == len(dia) == len(gai) == 1)
 return (frozenset(row[0]), frozenset(col[0]), frozenset(dia[0]), frozenset(gai[0]))

def attacks ( pos ) : row = filter ( ( lambda r : ( pos in r ) ) , posrows ) col = filter ( ( lambda c : ( pos in c ) ) , poscols ) dia = filter ( ( lambda d : ( pos in d ) ) , posdiag ) gai = filter ( ( lambda g : ( pos in g ) ) , posgaid ) assert ( len ( row ) == len ( col ) == len ( dia ) == len ( gai ) == 1 ) return ( frozenset ( row [ 0 ] ) , frozenset ( col [ 0 ] ) , frozenset ( dia [ 0 ] ) , frozenset ( gai [ 0 ] ) )
all attacked positions .