Class FindMissingNumber


  • public class FindMissingNumber
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static java.lang.Number findMultiplicationPattern​(java.math.BigDecimal[] numbers)
      Looks for multiplication pattern, on each step x multiplied or divided.
      protected static java.lang.Number findSumPattern​(java.math.BigDecimal[] numbers)
      Looks for sum pattern, on each step x is added or removed.
      static java.lang.Number testForPattern​(java.util.Collection<NumberRestriction> restrictions)
      Test if the values in constraints are in pattern.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MIN_NUMBER_OF_RESTRICTIONS

        public static final int MIN_NUMBER_OF_RESTRICTIONS
        See Also:
        Constant Field Values
    • Constructor Detail

      • FindMissingNumber

        public FindMissingNumber()
    • Method Detail

      • testForPattern

        public static java.lang.Number testForPattern​(java.util.Collection<NumberRestriction> restrictions)
        Test if the values in constraints are in pattern.
        Parameters:
        restrictions -
        Returns:
        false if can't find a pattern or constraints list is null or size of the list is under 3.
      • findSumPattern

        protected static java.lang.Number findSumPattern​(java.math.BigDecimal[] numbers)
        Looks for sum pattern, on each step x is added or removed. -x is the same as +(-x) so this works for both.
        Parameters:
        numbers -
        Returns:
        true if pattern is found.
      • findMultiplicationPattern

        protected static java.lang.Number findMultiplicationPattern​(java.math.BigDecimal[] numbers)
        Looks for multiplication pattern, on each step x multiplied or divided. *x is the same as *(1/x) so this works for both.
        Parameters:
        numbers -
        Returns:
        true if pattern is found.