Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1061727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:30:58+00:00 2026-05-16T18:30:58+00:00

I have a ridiculous code segment in one of my programs right now: str(len(str(len(var_text)**255)))

  • 0

I have a ridiculous code segment in one of my programs right now:

str(len(str(len(var_text)**255)))

Is there an easy way to shorten that? ‘Cause, frankly, that’s ridiculous.

A option to convert a number >500 digits to scientific notation would also be helpful
(that’s what I’m trying to do)

Full code:

print("Useless code rating:" , str(len(var_text)**255)[1] + "e" + str(len(str(len(var_text)**255))))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:30:58+00:00Added an answer on May 16, 2026 at 6:30 pm

    TL;DR: y = 2.408 * len(var_text)

    Lets assume that your passkey is a string of characters with 256 characters available (0-255). Then just as a 16bit number holds 65536 numbers (2**16) the permutations of a string of equal length would be

    n_perms = 256**len(passkey)
    

    If you want the number of (decimal) digits in n_perms, consider the logarithm:

    >>> from math import log10
    >>> log10(1000)
    3.0
    >>> log10(9999)
    3.9999565683801923
    >>> 
    

    So we have length = floor(log10(n_perms)) + 1. In python, int rounds down anyway, so I’d say you want

    n_perms = 256**len(var_text)
    length = int(log10(n_perms)) + 1
    

    I’d argue that ‘shortening’ ugly code isn’t always the best way – you want it to be clear what you’re doing.

    Edit: On further consideration I realised that choosing base-10 to find the length of your permutations is really arbitrary anyway – so why not choose base-256!

    length = log256(256**len(var_text)
    length = len(var_text) # the log and exp cancel!
    

    You are effectively just finding the length of your passkey in a different base…

    Edit 2: Stand back, I’m going to attempt Mathematics!

    if x = len(var_text), we want y such that
    y = log10(256**x)
    10**y = 256**x
    10**y = (10**log10(256))**x
    10**y = (10**(log10(256)x))
    y = log10(256) * x
    

    So, how’s this for short:

    length = log10(256) * len(var_text)     # or about (2.408 * x)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that looks somewhat like this (less ridiculous, of course): var d
I have a ridiculous question due to a ridiculous problem. Normally if I want
Have deployed numerous report parts which reference the same view however one of them
I have set ridiculous padding values and cannot get padding to extend the total
I have this code that works as posted: $('#cs_tableVideoListings tbody tr td').each( function() {
I have a question. It might be sound ridiculous, but let me explain what
I have two pages one is the main page and the another one is
There are a ridiculous amount of threads about and ways of doing this, I
It seems ridiculous (and a violation of DRY) to have to type the h
I am quite new on mvc3 and have some basic and ridiculous questions that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.