(Similar: Through the bases)
Normally, our number system is base ten, with the digits 0123456789
. However, we can increase or decrease the base count (so hexadecimal uses 0123456789abcdef
and octal uses 01234567
.
Your goal is: given a string, interpret it in all bases 2-36 for which it's valid, compute the total, and express that total in the smallest base that was valid for the original string.
The valid base characters are 0123456789abcdefghijklmnopqrstuvwxyz
. It is not case sensitive!
If it is invalid, return zero. There may be a sign for the first character (a +
or -
): if it is a -
, then return the result with a -
before it.
Test cases:
Xx -> 32s (base 34-36, in base 34, after lowercasing)
zzzzzz -> zzzzzz (36 is the only base that works, the number in base 36 is just "zzzzzz")
12 -> 1000002
MultiBase -> 8qa4f6laud
1v1 -> app
gy -> ye
+Huh -> 41ou
+h -> hh
abc -> 58b5b
-hello -> -k029mh
one -> hmm5
NaN -> k1hl
-Infinity -> -16di5ohk2
hello world -> 0
$0.99 -> 0
This is code-golf, so the shortest answer in bytes wins!
face
andFACE
are the same number. If you really intend case-sensitivity, please so state explicitly. \$\endgroup\$NaN
can be parsed in base 24 to base 36, for a total of 277485, which isk1hl
in base 24. I also get a different result for+Huh
. \$\endgroup\$