lib/combinatorial_puzzle_solver/solution_space.rb
# Iterates the possible values of unresolved identifiers and returns the solution
# space for the first attempt that yields a complete solution. It will return
# itself if it becomes resolved by eliminating the attempts that failed.
#
# @return [SolutionSpace] a solution space that is completely resolved
# @raise [Inconsistency] if no complete solution is found.
Iterates the possible values of unresolved identifiers and returns the solution
space for the first attempt that yields a complete solution. It will return
itself if it becomes resolved by eliminating the attempts that failed.
Iterates the possible values of unresolved identifiers and returns the solution space for the first attempt that yields a complete solution . It will return itself if it becomes resolved by eliminating the attempts that failed .
def resolve_by_trial_and_error!
      unresolved_identifiers.each{|identifier, possibilities|
        until possibilities.resolved? do
          maybe_value = possibilities.first
          maybe_solution = try_resolve_with(identifier, maybe_value)
          return maybe_solution unless maybe_solution.nil?
          resolve!(self[identifier].cannot_be!(maybe_value))
        end
      }
      self
    end
def resolve_by_trial_and_error! unresolved_identifiers . each { | identifier , possibilities | until possibilities . resolved? do maybe_value = possibilities . first maybe_solution = try_resolve_with ( identifier , maybe_value ) return maybe_solution unless maybe_solution . nil? resolve! ( self [ identifier ] . cannot_be! ( maybe_value ) ) end } self end
Iterates the possible values of unresolved identifiers and returns the solution
space for the first attempt that yields a complete solution.
Iterates the possible values of unresolved identifiers and returns the solution space for the first attempt that yields a complete solution .
a solution space that is completely resolved
a solution space that is completely resolved
SolutionSpace
[Inconsistency] if no complete solution is found.
[ Inconsistency ] if no complete solution is found .