Skip to content

Instantly share code, notes, and snippets.

@zindmax
Created January 11, 2022 16:13
Show Gist options
  • Save zindmax/c27ab00c3c431323c097fe73d2f82735 to your computer and use it in GitHub Desktop.
Save zindmax/c27ab00c3c431323c097fe73d2f82735 to your computer and use it in GitHub Desktop.
dolgi
import string
scheme =["0", "10", "1100", "1101", "1110" ,"1111"]
str = "abcdef"
code = ""
inp_str = "abccdf"
for x in inp_str:
ind = str.find(x)
print(scheme[ind], end ="")
code += scheme[ind]
str = str[ind] + str[:ind] + str[ind+1:]
print(str)
print(code)
str_1 = "abcdef"
res = ""
ind = ""
for i in code:
ind += i
if (ind in scheme):
res += str_1[scheme.index(ind)]
str_1 = str_1[scheme.index(ind)] + str_1[:scheme.index(ind)] + str_1[scheme.index(ind)+1:]
ind = ""
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment