Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- strT1 = str(indexT) + listStr[i + 1]
- '''
- Ziv Encoding
- '''
- str = "madma"
- listStr = [] # для строки сообщения
- listEn = []# для закодированного сообщения
- for i in str:
- listStr.append(i)
- #print(listStr)
- i = 0
- while(i < len(listStr)):
- if (i == 0):
- strT = ""# string to build a element of listEn
- strT = strT + "0" + listStr[i]
- listEn.append(strT)
- del strT
- j = 0
- while(j < len(listEn)):
- for k in range (0, len(listEn)):
- strT = ""
- strT = listEn[k]
- if (listStr[i] == strT[1:]):
- indexT = i + 1 # rememer the index of element to build the element of listEn
- strT1 = ""
- strT1 = str(indexT) + listStr[i + 1]
- listEn.append(strT1)
- del indexT
- del strT
- del strT1
- continue
- else:
- strT = ""# string to build a element of listEn
- strT = strT + "0" + listStr[i]
- listEn.append(strT)
- del strT
- j += 1
- i += 1
- print(listEn)
- str = "madma"
Add Comment
Please, Sign In to add comment