Share via

String Length Calculator

Anonymous
2024-05-19T03:42:34+00:00

I have an equation, namely 83x ^ 9 + 97x ^ 8 + 114x ^ 7 + 97x ^ 6 + 114x ^ 5 + 97x ^ 4 + 108x³ + 97x² + 110x + 100 = 135. That is a polynomial equation intended to convert a text string to decimal. In the example, it takes the Unicode indices of the letters in the name Sarasaland and converts the name from a given base (in this case, x) to decimal. What I would like to do is figure out the minimum base required to return a decimal conversion that is at least 135 digits long (henceforth, the “= 135” at the end of the equation). Considering a length of only 10 characters, the minimum base required to return a 135-digit result is probably no less than 10¹² (1 short-scale trillion).

Microsoft 365 and Office | Install, redeem, activate | Other | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2024-05-23T00:53:31+00:00

    I found a solution. It might be described as one of those “right under my nose” cases. I put in (18 + 65)x⁹ + (0 + 97)x⁸ + (17 + 97)x⁷ + (0 + 97)x⁶ + (18 + 97)x⁵ + (0 + 97)x⁴ + (11 + 97)x³ + (0 + 97)x² + (13 + 97)x + (3 + 97) = 10¹³⁴ (using the lowest target integer value rather than the integer length) (specifically in Wolfram|Alpha) and that returned the approximation that I needed.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-05-22T21:20:00+00:00

    Dear WadsDeirder

    Thank you for your reply.

    Your question requires a lot of calculations which are harder to implement in Excel, you can try to use code to implement the function.

    To find the minimum base ( b ) required to convert a given text string into a 135-digit integer, we can follow these steps:

    1. Convert the text string to a sequence of numbers: This involves assigning numerical values to each character in the string.
    2. Compute the numeric value in base ( b ): This involves calculating the sum of each character's value multiplied by the appropriate power of ( b ).
    3. Determine the base ( b ): Find the smallest ( b ) such that the resulting numeric value has 135 digits.

    Let's go through this process using the name "TEST" as an example.

    1. Convert the text string to a sequence of numbers:

       - "C" = 67 (ASCII value)

       - "h" = 104

       - "a" = 97

       - "t" = 116

       - "G" = 71

       - "P" = 80

       - "T" = 84

    2. Compute the numeric value in base ( b ):

       [

       \text{Value} = 67 \times b^6 + 104 \times b^5 + 97 \times b^4 + 116 \times b^3 + 71 \times b^2 + 80 \times b^1 + 84 \times b^0

       ]

    3.Determine the base ( b ):

       - We need to find the smallest ( b ) such that this value has 135 digits.

       - A number ( N ) has ( d ) digits if ( 10^{d-1} \leq N < 10^d ).

    We can use a binary search approach to find the minimum base more quickly.

    Here's the code:

    ```python
    
    def calculate_min_base_optimized(string, num_digits):
    
        # Convert string to sequence of ASCII values
    
        ascii_values = [ord(char) for char in string]
    
        length = len(ascii_values)
    
        # Function to calculate the numeric value in a given base
    
        def value_in_base(base):
    
            return sum(val * (base ** (length - 1 - idx)) for idx, val in enumerate(ascii_values))
    
        # Find the minimum base such that the value has the desired number of digits
    
        target_value = 10**(num_digits - 1)
    
        # Binary search for the minimum base
    
        low, high = 2, 10**5  # An upper limit guess
    
        while low < high:
    
            mid = (low + high) // 2
    
            if value_in_base(mid) >= target_value:
    
                high = mid
    
            else:
    
                low = mid + 1
    
        return low
    
    # Example usage
    
    string = "TEST"
    
    num_digits = 135
    
    min_base = calculate_min_base_optimized(string, num_digits)
    
    min_base
    
    ```
    

    If you still want to implement it in Excel, we suggest that you can post in the Microsoft Excel Tech community, where there are experts in this field who can provide more specialized solutions.

    Excel (microsoft.com)

    In closing, while I can't help you further, I hope the information I've provided has helped you find a better direction. If you need our assistance in the future, please feel free to contact us.

    Thank you for your understanding and patience.

    Best Regard

    Tracy | Microsoft Community Support Specialist

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-05-19T17:18:32+00:00

    Thank you for the reply, Tracy. The closest that I could think of for my post was to place it in the Excel category because I don’t know of a better place for it. What I would like to do is take, for example, your name, and convert it from a base (example: 128) to decimal such that the resulting integer is 135 digits long. In the example in this message, it looks like this: (19 + 65) × 128⁴ + (17 + 97) × 128³ + (0 + 97) × 128² + (2 + 97) × 128 + (24 + 97). This yields a result of 22,789,255,673. However, what I would like to do is find the minimum number to replace the base (128) by to yield a value that contains 135 digits. That is what I am uncertain of—how to quickly determine the minimum base needed to convert the text string to a 135-digit result. In the case of your name, the minimum base required might be 1 short-scale vigintillion (10 ^ 63).

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-05-19T10:49:21+00:00

    Dear WadsDeirder

    Welcome to the Microsoft Community, we are glad to assist you.

    We understand that you are experiencing a problem with string calculations, and in order to better assist you, we need to confirm some information with you.

    We noticed that your question was posted in the Office section, which program do you need to perform the calculation in? Is it Word or Excel?

    Or is it another program?

    Since the problem you mentioned involves calculations that are done differently in different software, we cannot give you a solution directly.

    If you can, please reply and share with us the software you are using so that we can better assist you.

    Thank you for your understanding and patience and I look forward to hearing from you.

    Best Regard

    Tracy | Microsoft Community Support Specialist

    Was this answer helpful?

    0 comments No comments