your task is...
Given a string x and a positive integer y, to determine whether there is a positive integer b and an injective mapping from the distinct characters in x to the digits of base b which permit us to interpret x as an integer equal to y.
If there is more than one base which works, you don't have to output all of them, just one.
The answer should be a function for those languages that support it, otherwise, code snippet
Your program should accept 0-9 and (a-z or A-Z) which are 36 characters. You don't have to care about kanji or snowman.
(e.g. 6 doesn't have to mean 6, it's just a symbol. basically you get a number in unknown base with unknown symbols and you have to substitute them to get y)
(foo,4) returns either 2 or 3 because
- f=1, o=0 -> 1002=410
- f=0, o=1 -> 0113=410
(10,10) any integer greater than 4 but not 9 because
- 1=2, 0=0 -> 205=1010
- 1=1, 0=4 -> 146=1010
- 1=1, 0=3 -> 137=1010
- 1=1, 0=2 -> 128=1010
- 1=1, 0=0 -> 1010=1010
- 1=0, 0=10 -> 0111=1010
- above base 10, 1=0, 0=10 -> 01x=1010 for every
x > 10
(611,1) returns 0 which means there is no possible base for
611 meaning 110
You have to output every possible base, not just one. I know it can be infinite,
indicate it somehow.
2,3,... for example.
Answers with bonus gain a 0.7 multiplier.