What your function must do:
be as short (in bytes) as possible
take 3 inputs that are strings: number , fromdigits, todigits
assume no digit is repeated in fromdigits or todigits
assume fromdigit and todigit contain only alphanumeric characters
assume number is a natural number
output (a string): number converted to frombase
examples:
convert("ff","0123456789abcdef","0123456789")="255"
convert("ee","fecdba9876543210","9876543210")="82"
example code (283 bytes, in python 3.4.1):
def convert(number,fromdigits,todigits):
x=0
for digit in str(number):
x = x*len(fromdigits)+fromdigits.index(digit)
res=""
while x>0:
digit = x % len(todigits)
res = todigits[digit] + res
x //= len(todigits)
return res
convert("ff","0123456789abcdef","0123456789")
call should be255
instead of256
\$\endgroup\$