(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
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
-): if it is a
-, then return the result with a
- before it.
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!