diff options
Diffstat (limited to 'challenge-002/zapwai/python/ch-2.py')
| -rw-r--r-- | challenge-002/zapwai/python/ch-2.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-002/zapwai/python/ch-2.py b/challenge-002/zapwai/python/ch-2.py new file mode 100644 index 0000000000..d26bd231eb --- /dev/null +++ b/challenge-002/zapwai/python/ch-2.py @@ -0,0 +1,16 @@ +alph = "0123456789abcdefghijklmnopqrstuvwxy" + +def to10(s): + return int(s, 35) + +def to35(s): + q = s; + o = "" + while ( q > 0 ): + rem = q % 35 + o = alph[rem] + o + q //= 35 + return o + +print("Input: (base-10) 100\nOutput: ", to35(100)) +print("Input: (base-35) 2u\nOutput: ", to10("2u")) |
