Created
August 19, 2018 18:05
-
-
Save domarps/4b74333c83266ddfacf1b7ab5792e902 to your computer and use it in GitHub Desktop.
TautDefiantGraduate created by domarps - https://repl.it/@domarps/TautDefiantGraduate
This file contains 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
from random import choice | |
import string | |
def compress_string(s): | |
if len(s) < 3: | |
return 0 | |
max_len = len(s) - 2 | |
str_list = [] | |
for num in range(len(s), 2, -1): | |
for i in range(1, len(s) - num): | |
str_list.append(s[0:i] + str(num) + s[i+num+1:]) | |
return len(str_list) | |
results = [] | |
for n in range(100): | |
input = ''.join([choice(string.ascii_letters) for j in range(n)]) | |
result = compress_string(input) | |
results.append(result) | |
print(results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment