Skip to content

Instantly share code, notes, and snippets.

@TuxPenguin09
Last active May 19, 2022 23:00
Show Gist options
  • Save TuxPenguin09/c13268d1047214fa65e40bdc657d4db5 to your computer and use it in GitHub Desktop.
Save TuxPenguin09/c13268d1047214fa65e40bdc657d4db5 to your computer and use it in GitHub Desktop.
Calculating How Many Random String Until Everything is Mentioned in Python
import random
stringAlphabets = "abcdefghijklmnopqrstuvwxyz"
stringAvail = []
strAvlength = 0
strLimlength = 0
strErrs = 0
charLength = 15 # Any length of chars
limitDone = True
while(limitDone):
stringRand = "".join(random.choice(stringAlphabets) for _ in range(charLength))
print("Live Count of String Avail: " + str(strAvlength) + " String: " + stringRand + ", Errors: " + str(strErrs), end="\r")
if stringRand not in stringAvail:
strAvlength = strAvlength + 1
strLimlength = 0
stringAvail.append(stringRand)
else:
strErrs = strErrs + 1
strLimlength = strLimlength + 1
if strLimlength == 10000:
print("\nFinished calculating!")
limitDone = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment