reasoning with constraints exercise propose test that is appropriate for csps with no solutions assume that the test designer knows there are no solutions consider what csp solver should return if there are no solutions to the csp exercise write unit test that checks whether all solutions ( for the search algorithms that can return multiple solutionsare correctand whether all solutions can be found simple depth-first solver the first solver searches through the space of partial assignments this takes in csp problem and an optional variable orderingwhich is list of the variables in the csp it returns generator of the solutions (see python documentation on yield for enumerationscspdfs py -solving csp using depth-first search from cspexamples import csp ,csp ,test_cspcrossword crossword def dfs_solver(constraintscontextvar_order)"""generator for all solutions to csp context is an assignment of values to some of the variables var_order is list of the variables in csp that are not in context ""to_eval { for in constraints if can_evaluate(context)if all( holds(contextfor in to_eval)if var_order =[]yield context elserem_cons [ for in constraints if not in to_evalvar var_order[ for val in var domainyield from dfs_solver(rem_conscontext|{var:val}var_order[ :] def dfs_solve_all(cspvar_order=none)"""depth-first csp solver to return list of all solutions to csp ""if var_order =noneuse an arbitrary variable order var_order list(csp variablesreturn listdfs_solver(csp constraints{}var_order) def dfs_solve (cspvar_order=none)"""depth-first csp solver to find single solution or none if there are no solutions ""if var_order =noneuse an arbitrary variable order var_order list(csp variablesgen dfs_solver(csp constraints{}var_ordertrypython generators raise an exception if there are no more elements version june