# This simple code takes a string as input and outputs the optimal baseX

def get_optimal_baseX(string):
    alphabet = string.encode()
    min_count = float('inf')
    optimal_baseX = 0
    for baseX in range(2, len(alphabet) + 1):
        encoded = encode_baseX(string, alphabet)
        count = len(encoded) - len(string)
        if abs(count) < min_count:
            min_count = abs(count)
            optimal_baseX = baseX
    return optimal_baseX
  
# Test
string = 'Hello World!'
optimal_baseX = get_optimal_baseX(string)
print('Optimal baseX for string "{}" is {}'.format(string, optimal_baseX))
# Output: Optimal baseX for string "Hello World!" is 12

# By Josef Kulovany - https://zchg.org - DO NOT REMOVE PER LICENSE AND COPYRIGHT LAW
