#NEWLINE# def setUp( self ) : #NEWLINE# #INDENT# self . variables = ( 'A' , 'B' , 'C' ) #NEWLINE# self . domains = { #NEWLINE# #INDENT# 'A' : [ 1 , 2 , 3 ] , #NEWLINE# 'B' : [ 1 , 3 , 4 ] , #NEWLINE# 'C' : [ 1 , 2 ] , #NEWLINE# #UNINDENT# } #NEWLINE# def const_different( variables , values ) : #NEWLINE# #INDENT# return ( len ( values ) == len ( set ( values ) ) ) #NEWLINE# #UNINDENT# def const_one_bigger_other( variables , values ) : #NEWLINE# #INDENT# return ( values [ 0 ] > values [ 1 ] ) #NEWLINE# #UNINDENT# def const_one_odd_one_even( variables , values ) : #NEWLINE# #INDENT# if ( ( values [ 0 ] % 2 ) == 0 ) : #NEWLINE# #INDENT# return ( ( values [ 1 ] % 2 ) == 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( ( values [ 1 ] % 2 ) == 0 ) #NEWLINE# #UNINDENT# #UNINDENT# def const_not_1( variables , values ) : #NEWLINE# #INDENT# return ( values [ 0 ] != 1 ) #NEWLINE# #UNINDENT# self . constraints = [ ( ( 'A' , 'B' , 'C' ) , const_different ) , ( ( 'A' , 'C' ) , const_one_bigger_other ) , ( ( 'A' , 'C' ) , const_one_odd_one_even ) , ( ( 'A' , ) , const_not_1 ) ] #NEWLINE# self . problem = CspProblem ( self . variables , self . domains , self . constraints )