Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for The Good Radix by Vivek
# migrated from python 2.7
def checkio(number):
"""
Your solution
"""
base = int(max([char for char in number]),36) + 1
for x in range(base,37):
value = int(number, x)
if value%(x-1)==0:
return x
return 0
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("18") == 10, "Simple decimal"
assert checkio("1010101011") == 2, "Any number is divisible by 1"
assert checkio("222") == 3, "3rd test"
assert checkio("A23B") == 14, "It's not a hex"
print('Local tests done')
Aug. 27, 2013
Comments: