<s> from simpleai . search import CspProblem , backtrack , min_conflicts , MOST_CONSTRAINED_VARIABLE , HIGHEST_DEGREE_VARIABLE , LEAST_CONSTRAINING_VALUE <EOL> variables = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:T>' ) <EOL> domains = dict ( ( v , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) for v in variables ) <EOL> def const_different ( variables , values ) : <EOL> return values [ <NUM_LIT:0> ] != values [ <NUM_LIT:1> ] <EOL> constraints = [ <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , const_different ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , const_different ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , const_different ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , const_different ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , const_different ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , const_different ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , const_different ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , const_different ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , const_different ) , <EOL> ] <EOL> my_problem = CspProblem ( variables , domains , constraints ) <EOL> print backtrack ( my_problem ) <EOL> print backtrack ( my_problem , variable_heuristic = MOST_CONSTRAINED_VARIABLE ) <EOL> print backtrack ( my_problem , variable_heuristic = HIGHEST_DEGREE_VARIABLE ) <EOL> print backtrack ( my_problem , value_heuristic = LEAST_CONSTRAINING_VALUE ) <EOL> print backtrack ( my_problem , variable_heuristic = MOST_CONSTRAINED_VARIABLE , value_heuristic = LEAST_CONSTRAINING_VALUE ) <EOL> print backtrack ( my_problem , variable_heuristic = HIGHEST_DEGREE_VARIABLE , value_heuristic = LEAST_CONSTRAINING_VALUE ) <EOL> print min_conflicts ( my_problem ) </s>
