Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Number Base by Bartlomiej_Szal
import string
def value(char):
numbers = '0123456789'
letters = string.ascii_uppercase
if numbers.find(char) != -1:
value = int(char)
elif letters.find(char) != -1:
value = letters.find(char) + 10
return value
def maxValue(number):
maxi = 0
for i in range(len(number)):
if value(number[i]) > maxi:
maxi = value(number[i])
return maxi
def checkio(str_number, radix):
if maxValue(str_number) < radix:
return int(str_number, radix)
else:
return -1
Oct. 9, 2016
Comments: