³ò
$?Ic           @   s¡   d o e  n d o e e e e n d d k Z d o e n d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z e ƒ  d S(   i@   iA   iÿÿÿÿNiI   c          C   si  g  g  g  g  g  g  g  g }  d
 o t  n d o t t t i n d o t t n d o t t t	 t
 n d o t t t t n d o t t n d o t i t t t t n t i ƒ  } | i ƒ  g  } xB t d ƒ D]4 } x+ t d	 ƒ D] } |  | i | i ƒ  ƒ qþ Wqë W| i | i ƒ  ƒ | | |  f Sd o t t	 i t t t n d  S(   NiW   i   iI   i^   ia   i   id   i   i   i    i    i    i    i    i    i    i    (   t   OoOoOO00t   OOOo0t   Oot   Ooo00oOo00ot   I1IiIt   OOooOOot	   ii11ii1iit   OoOOt   OoOO0ooOOoo0Ot   o0000oOoOoO0ot   o00O0oot	   oO0o0ooO0t   IIIIt   O0oOt   O0t   i1IIit
   OoooooooOOt   cardst   Deckt   shufflet   ranget   appendt   deal(   t   iIiiiI1IiI1I1t   O0IiiiIiI1iIiI1t   ooo0Oo0t   oot   O0Oooo00(    (    s   golfRelaxedObfuscated.pyt   IiII1IiiIiI1   s6           
   c         C   s+  Hd o t  t t t t n d o t t t t n d o t t t t  t n d o t	 t
 t t t n d o t t n d } d GHx6 | D]. } d G| Gx | D]
 } | Gq³ W| d 7} Hqž Wd GHd	 G| o x | D]
 } | Gqç Wn Hd GHd
 G|  i ƒ  Gd GHHHd o t  t n d  S(   Ni   ic   i,   i6   i   t   Tableaus   Row:s
   ----------s   Foundation:s   Stock:s
   cards lefti2   i    i    i    i    i    i    (   t
   i11iIiiIiiR    R   R   R   t   iIii1I11I1II1R   t	   II111iiiiR   R   R   R
   R   R   t
   cards_leftR	   (   t   stockt   fdationt   tableaut   i11IiIiiIIIIIt   i1iiIII111iit   i1iIIi1(    (    s   golfRelaxedObfuscated.pyt   O0I11i1i11i1I   sF           
  c         C   sB  | |  d pš d
 o t  t  t t t n d o t t t t t t n d o t	 t n d o t
 i
 t
 t t n d o t t t  t t n t Sn | |  d d } | i ƒ  } | d i ƒ  } | | d j p3 | | d j p" | | d j p | | d j o t Sn t Sd o t t t n d  S(   Ni   i.   i7   i   iF   iV   iÿÿÿÿi   i   i    i    i    i    i    i    (   R   R   R   R
   R   R   R	   R   R    R   R   R   R   R   R   t   Falset   get_rankt   TrueR    R   (   t   tRowR$   R#   t   oOoOt   oOot   oOoOoO(    (    s   golfRelaxedObfuscated.pyt   oo0Ooo02   s(         D c         C   s÷   t  |  | | ƒ o‰ d o t n d o t t t t t n d o t n d o t t	 t t i
 n d o t n | i | |  d i ƒ  ƒ nX | |  d o d | |  d d GHn0 d	 G|  GHd o t t t n d o t n d  S(   Ni   i   ia   i    i=   i   s'   Error, cannot move %s to the foundationiÿÿÿÿs   Empty row in tableau atiO   iS   i    i    i    i    i    i    i    (   R0   R   R   R	   R   R   R
   R   R   R   R   R   R   t   popR    (   R,   R$   R#   (    (    s   golfRelaxedObfuscated.pyt   ooOO0O00A   s&         	  c         C   sÜ   |  i  ƒ  o¥ d o t t t t t t n d	 o t t t n d
 o t t t t i	 n d o t
 t t t n d o t n d o t t t t
 n t Sn | i |  i ƒ  ƒ t Sd o t n d  S(   Ni   iP   i	   i   i   i   i   i    i    i    i    i    i    i    (   t   emptyR   R   R   R   R   R   R   R	   R   R   R    R   R   R)   R   R   R+   (   R"   R#   (    (    s   golfRelaxedObfuscated.pyt
   OO00o0OOO0O   s$           c         C   s-  d
 o t  t i t t t n xÄ |  D]¼ } d o t t t t t n d o t	 t t t i
 t	 n d o t  t t  t t n d o t t i t t  t n d o t i t
 n t | ƒ d j o q) q) t Sq) Wt Sd o t t t
 t i  t n d o t t i  t n d  S(   Ni   i=   iK   iG   iA   i3   i    i
   i   i    i    i    i    i    i    i    i    (   R   R   R   R   R   R   R   R   R   R   R    R	   R    R   R   R   R   t   lenR)   R+   (   R$   t   oOoOooOo0o0(    (    s   golfRelaxedObfuscated.pyt   iI[   s,             c         C   st  d o t  t n |  i ƒ  pè d o t  t t t n d o t  t t t n d o t t	 t t
 n d o t t t t	 t n d o t t	 t
 t t t n d o t t t t n d o t t n d o t t t t t n t Sn x3 t d
 ƒ D]% } t | d | | ƒ o t SqqWt Sd o t t  t n d o t t t n d  S(   Ni    ic   i   i   i2   iX   i   i:   iG   i   i   i    i    i    i    i    i    i    i    i    i    i    (   R   R   R3   R   R   R	   R   R   R   R   R
   R    R   R   R   R   R   R   R   R   R)   R   R0   R+   R    (   R"   R#   R$   R   (    (    s   golfRelaxedObfuscated.pyt   I11IIj   s:                c           C   sÉ   d GHd o t  t t i n d o t t t t t n d o t n d o t t	 n d o t
 i n d GHd GHd	 GHd
 GHd GHd GHd GHd GHHd o t n d o t t
 t t	 n d  S(   Ns   Rules of Golf Relaxedi   i-   i   i>   i   s*   Goal, move all the cards to the foundations=   1) All cards move from the tableau (7 rows) to the foundations=   2) Only the last card in each row of the tableau can be movedsN   3) You may move a card from the tableau to the foundation when there is a cardsW      in the tableau whose rank is adjacent to the rank of the top card of the foundation.s)      Ace and King are considered adjacent. sP   4) If there are remaining card(s) in the stock. You may deal one card at a time s!      to the top of the foundation. iD   i#   i    i    i    i    i    i    i    (   R   R   R   R   R   R    R   R   R	   R   R
   R   R   (    (    (    s   golfRelaxedObfuscated.pyt   Oo000o|   s0           c          C   sß  t  ƒ  d o t n d o t t t t t t n d o t t t i n t ƒ  \ }  } } d o t	 n d GHd GHd GHt
 } x0| o(t |  | | ƒ t |  | | ƒ o  d GHPd  o t i t qÖ n t d
 ƒ } | i ƒ  } | i ƒ  } t | ƒ d j o¡ | d } | d! j o6 t t | ƒ | | ƒ t | ƒ o t } d GHqªq·| d j o# t |  | ƒ } | p	 d GHqªq·| d j o
 t } q·d G| GHqŒ d G| GHqŒ Wd GHd" o t i t t n d  S(#   NiK   i2   i[   i   s3   Responses are: '1-7' card to move to the foundations   	 'd' to deal one cards   	 'q' to quits	   You lose!i   s   Command:i   i    t   1t   2t   3t   4t   5t   6t   7s   You won!t   dsV   There is no card left in stock. You may quit if you can't move any cards from tableau!t   qs   Unknown command:s   Unknown Command:s   Thanks for playingiA   i    i    i    i    i    (   R:   R;   R<   R=   R>   R?   R@   i    (   R9   R   R	   R   R   R
   R   R    R   R   R+   R(   R8   R   R   R   t	   raw_inputt   stript   splitR5   R2   t   intR7   R)   R4   R   (   t   i1I11i1It   Oo0o00t   O0O0oOO00O00ot   Oo00t   o000O0ot   iI1iII1R6   t
   oO0OOoo0OO(    (    s   golfRelaxedObfuscated.pyt   I1i1IiI1Ž   sV          

 i    i    i    (   R   R   R   R   R   R   R    R   R(   R0   R2   R4   R7   R8   R9   RN   (    (    (    s   golfRelaxedObfuscated.pys   <module>   s       									'