???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................ó
Afc           @   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   &   s    c         C   s@   | |  j  | <d |  j | <d |  j | | <d |  j | | <d  S(   Ni   (   R   R   R   R	   (   R   R   R   (    (    s+   /usr/lib64/python2.7/Demo/scripts/queens.pyR   )   s    c         C   s@   d  |  j | <d |  j | <d |  j | | <d |  j | | <d  S(   Ni    (   R   R   R   R   R	   (   R   R   R   (    (    s+   /usr/lib64/python2.7/Demo/scripts/queens.pyR   /   s    c         C   s®   |  j  d |  _  |  j r d  Sd d |  j d GHxb t |  j d d d ƒ D]G } d Gx5 t |  j ƒ D]$ } |  j | | k r… d Gqe d Gqe Wd GHqK Wd d |  j d GHd  S(	   Ni   s   +-s   --t   +iÿÿÿÿt   |t   Qt   .(   R
   t   silentR   R   R   (   R   R   R   (    (    s+   /usr/lib64/python2.7/Demo/scripts/queens.pyR   7   s    	 	(   t   __name__t
   __module__t   NR   R   R   R   R   R   R   R   (    (    (    s+   /usr/lib64/python2.7/Demo/scripts/queens.pyR       s   	
			c          C   sš   d d  l  }  d } t } |  j d d !d g k rD d } |  j d =n  |  j d rg t |  j d ƒ } n  t | ƒ } | | _ | j ƒ  d G| j Gd GHd  S(   Niÿÿÿÿi    i   i   s   -nt   Founds
   solutions.(   t   sysR   t   argvt   intR    R   R   R
   (   R   R   R   t   q(    (    s+   /usr/lib64/python2.7/Demo/scripts/queens.pyt   mainF   s    	
t   __main__N(    (   t   __doc__R   R    R   R   (    (    (    s+   /usr/lib64/python2.7/Demo/scripts/queens.pyt   <module>
   s
   8	