Skip to content

Instantly share code, notes, and snippets.

@timelessnesses
Created August 1, 2021 13:01
Show Gist options
  • Save timelessnesses/f85b2de4f42cc92322deeee6debb2fae to your computer and use it in GitHub Desktop.
Save timelessnesses/f85b2de4f42cc92322deeee6debb2fae to your computer and use it in GitHub Desktop.
Same string speed run challenge
while True:
from random import sample
from datetime import timedelta
from time import time, sleep
from os import system
from string import ascii_letters, digits
inp = int(input("String length : "))
ainp = input("Upper or normal?")
count = 1
system("clear")
now = time()
while True:
if ainp.lower() is "normal":
old = "".join(sample(ascii_letters + digits, inp))
new = "".join(sample(ascii_letters + digits, inp))
else:
old = "".join(sample(ascii_letters + digits, inp)).upper()
new = "".join(sample(ascii_letters + digits, inp)).upper()
if old == new:
print(
f"Found correct {new} & {old} Count {count}\n\rUse time {timedelta(seconds=time() - now)}",
end="\r",
)
break
print(
f"Not correct {new} & {old} Count {count}\n\rUse time {timedelta(seconds=time() - now)}",
end="\r",
)
count += 1
sleep(2)
print("\n\n",end="\r")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment