Beispiel #1
0
        /// <summary>
        /// Determine if a potential solution value is still possible
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when argument is too small or too large</exception>
        /// <param name="value">Value to check</param>
        public bool IsPotentialSolution(char value)
        {
            // Range validation
            if (value < MinValue || value > MaxValue)
            {
                throw new ArgumentOutOfRangeException("IsPotentialSolution",
                                                      string.Format("Argument ({0:d}) must be between {1} and {2}",
                                                                    value, MinValue, MaxValue));
            }

            // True if not yet disqualified
            return(RemainingPossibilities.Contains(value));
        }
Beispiel #2
0
        /// <summary>
        /// Remove a potential solution value from consideration
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when argument is too small or too large</exception>
        /// <param name="value">Value to exclude from consideration</param>
        public void Disqualify(char value)
        {
            // Range validation
            if (value < MinValue || value > MaxValue)
            {
                throw new ArgumentOutOfRangeException("Disqualify",
                                                      string.Format("Argument ({0:d}) must be between {1} and {2}",
                                                                    value, MinValue, MaxValue));
            }

            // Remove if value is currently qualified; ignore (benignly) if previously disqualified
            if (RemainingPossibilities.Contains(value))
            {
                RemainingPossibilities.Remove(value);
            }
        }