lib/combinatorial_puzzle_solver/constraint.rb
# Iterates all possible values that can be set within this constraint, and
# when a value can only be placed within that specific identifier.
#
# @param solution_space [SolutionSpace] the mapping between the puzzle's
#                                       identifiers and the values they can have.
# @param resolvable [Hash<Identifier,Object>] an optional Hash to store all
#                                             identifiers and values that becomes
#                                             resolvable.
# @return [Hash<Identifier,Object>] the identifiers that can be resolved, mapped
#                                   to the only value they can have.
Iterates all possible values that can be set within this constraint, and
when a value can only be placed within that specific identifier.
Iterates all possible values that can be set within this constraint and when a value can only be placed within that specific identifier .
def resolvable_identifiers(solution_space, resolvable=Hash.new)
      possible_values(solution_space).each{|value, identifiers|
        if identifiers.size == 1 then
          resolved_identifier = identifiers.first
          unless solution_space[resolved_identifier].resolved? then
            resolvable[resolved_identifier] = value
          end
        end
      }
      resolvable
    end
def resolvable_identifiers ( solution_space , resolvable = Hash . new ) possible_values ( solution_space ) . each { | value , identifiers | if identifiers . size == 1 then resolved_identifier = identifiers . first unless solution_space [ resolved_identifier ] . resolved? then resolvable [ resolved_identifier ] = value end end } resolvable end
Iterates all possible values that can be set within this constraint, and
when a value can only be placed within that specific identifier.
Iterates all possible values that can be set within this constraint and when a value can only be placed within that specific identifier .
the identifiers that can be resolved, mapped to the only value they can have.
the identifiers that can be resolved mapped to the only value they can have .
Hash<Identifier,Object>
solution_space
the mapping between the puzzle's identifiers and the values they can have.
the mapping between the puzzle ' s identifiers and the values they can have .
resolvable
an optional Hash to store all identifiers and values that becomes resolvable.
an optional Hash to store all identifiers and values that becomes resolvable .
new
<not_specific>