object ABCDEFGHPPP
Problem: (AB − CD = 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:
- PPP can't be 000, by adding two 2-digit numbers.
- PPP can't be 222 or greater, by subtracting two 2-digit numbers.
- PPP can't be anything else, so PPP can only be 111.
- Alphabetic
- By Inheritance
- ABCDEFGHPPP
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws(classOf[java.lang.CloneNotSupportedException])
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- 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
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- 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.- For octal (base 8), there are zero cases of 9 values.
- For decimal (base 10), this is 3,628,800 values.
- For hex (base 16), this is 4,151,347,200 values.
- 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
- final def synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws(classOf[java.lang.InterruptedException])