//usr/lib64/lib64//lib64//python2.7/ó
V
Qc @ sB d Z d Z d d d „ ƒ YZ d „ Z e d k r> e ƒ n d S( s¹ N queens problem.
The (well-known) problem is due to Niklaus Wirth.
This solution is inspired by Dijkstra (Structured Programming). It is
a classic recursive backtracking approach.
i t Queensc B sS e Z e d „ Z d „ Z d d „ Z d „ Z d „ Z d „ Z d Z d „ Z
RS( c C s | | _ | j ƒ d S( N( t nt reset( t selfR ( ( s+ /usr/lib64/python2.7/Demo/scripts/queens.pyt __init__ s c C sf | j } d g | | _ d g | | _ d g d | d | _ d g d | d | _ d | _ d S( Ni i i ( R t Nonet yt rowt upt downt nfound( R R ( ( s+ /usr/lib64/python2.7/Demo/scripts/queens.pyR s i c C s„ x} t | j ƒ D]l } | j | | ƒ r | j | | ƒ | d | j k rX | j ƒ n | j | d ƒ | j | | ƒ q q Wd S( Ni ( t rangeR t safet placet displayt solvet remove( R t xR ( ( s+ /usr/lib64/python2.7/Demo/scripts/queens.pyR s
c C s0 | j | o/ | j | | o/ | j | | S( N( R R R ( R R R ( ( s+ /usr/lib64/python2.7/Demo/scripts/queens.pyR &