Given 3 integers, determine the lowest possible base for the first two integers to multiply into the third. If you think of the Answer to the Ultimate Question of Life, The Universe, and Everything, 6 * 9 == 42, is true in Base 13.
The inputs can include any numbers whose digits use the characters 0-9, a-z, and A-Z, where a
equals 10 in Base 10, and Z
is 61 in Base 10.
The inputs should be inputted in any way you like (except for hard-coding), and you can write either an individual function or an entire program.
The maximum base that must be considered is Base 62, and the minimum base is Base 2.
You can assume that the first two values are smaller than the third. You can also conclude that the minimum base is one greater than the highest digit/character from the inputs (for example, if the inputs are 3 1a 55
, the minimum base would be Base 11, because a
is the highest digit).
If there is no such base, return a junk value of your choice.
This is code golf, so the shortest code wins.
Test Cases
6 9 42 --> 13
a a 64 --> 16
aA bB 36jk --> 41
2 3 20 --> <junk value>
10 10 100 --> 2
b
in a general way likea_0 b^0 + a_1 b^1 + a_2 b^2 + ...
(wherea_0
is the least significant digit) than base 1 definitely makes sense. Furthermore, the OP's conclusion would also include base 1 in the search if the largest present digit is 0. \$\endgroup\$