Packages

  • package root
    Definition Classes
    root
  • object ABCDEFGHPPP

    Problem: (ABCD = EF) + GH = PPP

    Problem: (ABCD = EF) + GH = PPP

       AB
     - CD
    -----
       EF
     + GH
    -----
      PPP
    

    The values for A, B, C, D, E, F, G, H, and P are distinct and in the range of [0, 9].

    It is not possible to sum two numbers and get zero, unless they are also zero, so P can't be zero.

    The two-digit numbers should be actual two-digit numbers, so A, C, E, G cannot be 0.

    Example:

    ABCDEFGHPPP.solve(10) // Decimal

    It's possible to solve for other base number systems than just decimal:

    ABCDEFGHPPP.solve(16) // Hex system

    However, a brute-force heuristic is used, so complexity severely limits the capability to solve bases larger than 16.

    There is an important optimization available for filtering out possible solutions based on the following assumptions about P:

    1. PPP can't be 000, by adding two 2-digit numbers.
    2. PPP can't be 222 or greater, by subtracting two 2-digit numbers.
    3. PPP can't be anything else, so PPP can only be 111.
    Definition Classes
    root
o

ABCDEFGHPPP

object ABCDEFGHPPP

Problem: (ABCD = EF) + GH = PPP

   AB
 - CD
-----
   EF
 + GH
-----
  PPP

The values for A, B, C, D, E, F, G, H, and P are distinct and in the range of [0, 9].

It is not possible to sum two numbers and get zero, unless they are also zero, so P can't be zero.

The two-digit numbers should be actual two-digit numbers, so A, C, E, G cannot be 0.

Example:

ABCDEFGHPPP.solve(10) // Decimal

It's possible to solve for other base number systems than just decimal:

ABCDEFGHPPP.solve(16) // Hex system

However, a brute-force heuristic is used, so complexity severely limits the capability to solve bases larger than 16.

There is an important optimization available for filtering out possible solutions based on the following assumptions about P:

  1. PPP can't be 000, by adding two 2-digit numbers.
  2. PPP can't be 222 or greater, by subtracting two 2-digit numbers.
  3. PPP can't be anything else, so PPP can only be 111.
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ABCDEFGHPPP
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws(classOf[java.lang.CloneNotSupportedException])
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. def listToTuple9(xs: Seq[Byte]): (Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte)

    Convert list of 9 integers to a 9 integer tuple.

    Convert list of 9 integers to a 9 integer tuple.

    Otherwise, throw a runtime error.

    xs

    List of 9 integers

    returns

    The 9 integers of the list in the same order

    Exceptions thrown

    java.lang.IllegalArgumentException When not exactly 9 elements

  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. def solve(radix: Int): Iterator[(Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte)]

    Solve ABCDEFGHPPP for radix using brute-force.

    Solve ABCDEFGHPPP for radix using brute-force.

    Generates all permutations of the distinct range 0 to radix:

    For radix of n, tries n! / (n − 9)! possible solutions.

    1. For octal (base 8), there are zero cases of 9 values.
    2. For decimal (base 10), this is 3,628,800 values.
    3. For hex (base 16), this is 4,151,347,200 values.
    4. For vigesimal (base 20), this is 60,949,324,800.
    radix

    Base number system

    returns

    Nothing

    Exceptions thrown

    java.lang.IllegalArgumentException When radix 8 or less

  17. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  18. def toString(): String
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  20. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws(classOf[java.lang.InterruptedException])

Inherited from AnyRef

Inherited from Any

Ungrouped