def encode (plainText):
res=''
a=''
for i in plainText:
if a.count(i)>0:
a+=i
else:
if len(a)>3:
res+="/" + str(len(a)) + a[0][:1]
else:
res+=a
a=i
return(res)
this is my current code.
(这是我当前的代码。)
for those of you who know about run length encoding, it can make files larger because a single value becomes two. (对于那些了解游程长度编码的人来说,它可以使文件变大,因为单个值变为两个。)
I am trying to set a minimum length of 3, so that it would actually compress. (我正在尝试将最小长度设置为3,以使其实际压缩。)
any help with code corrections, suggestions are greatly appreciated. (任何有关代码更正的帮助,建议将不胜感激。)
ask by tre rossi translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…