I would like to know how to define a new numerical base in Python.
For example:
base dimension = 4
Charset = 'u', '$', '6', '}' (from the least important to the most)
I would like to know how to create and handle it, to be able to do simple arithmetic like:
$} + 6u * 6 = $$}
7 + 8 * 2 = 23
I know I could use replace
to replace u -> 0
, $ -> 1
and so on, and use the int()
function. However int()
is not defined for base > 36
, and I will have to handle these cases.
I know I could make my own function to convert them to base 10
, do the math, and convert them back, but I would like to avoid that if possible.