code: def _least_constraining_values_sorter(problem, assignment, variable, domains):
      '''
      Sort values based on how many conflicts they generate if assigned.
      '''
      def update_assignment(value):
          new_assignment = deepcopy(assignment)
          new_assignment[variable] = value
          return new_assignment
      values = sorted(domains[variable][:],
                      key=lambda v: _count_conflicts(problem, assignment,
                                                     variable, v))
      return values