def isIncrAlpha(a, strict = True):
""" input string such as a number in a base higher than 10. Determine if
characters are strictly increasing.
Set second parameter to False to remove the strict restriction"""
a = str(a)
a = a.upper()
l = [ord(i) for i in a]
for i,c in enumerate(l):
if i == 0:
x = c
else:
if strict:
if c <= x:
return False
else:
x = c
else:
if c < x:
return False
else:
x = c
return True
def isDecrAlpha(a, strict = True):
""" input string such as a number in a base higher than 10. Determine if
characters are strictly decreasing.
Set second parameter to False to remove the strict restriction"""
a = str(a)
a = a.upper()
l = [ord(i) for i in a]
for i,c in enumerate(l):
if i == 0:
x = c
else:
if strict:
if c >= x:
return False
else:
x = c
else:
if c > x:
return False
else:
x = c
return True
decimalMaxIncr12 = int(base2base('123456789AB',12,10)**.5)
decimalMaxDecr12 = int(base2base('BA9876543210',12,10)**.5)
print('Increasing')
print('decimal', 'square', 'base12')
for n in range(decimalMaxIncr12,0,-1):
x = base2base(n*n,10,12)
if isIncrAlpha(x):
print(n, '\t', n**2,'\t', x)
print('')
print('Decreasing')
print('decimal', 'square', 'base12')
for n in range(decimalMaxDecr12,0,-1):
x = base2base(n*n,10,12)
if isDecrAlpha(x):
print(n, '\t', n**2, '\t', x)