Created
August 1, 2021 13:01
-
-
Save timelessnesses/f85b2de4f42cc92322deeee6debb2fae to your computer and use it in GitHub Desktop.
Same string speed run challenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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