New Features in Python 1.6
Amit Patel
amitp at Xenon.Stanford.EDU
Tue Apr 4 22:42:45 EDT 2000
Philip 'Yes, that's my address' Newton <nospam.newton at gmx.li> wrote:
|
| Yes? I challenge you to provide any algorithm that will strip away one
| bit from the four sequences 11, 10, 01, and 00, while still being able
| to restore the previous state. (Unless you were talking about lossy
| compression, in which case you might as well say "my compression
| algorithm just drops off the leftmost bit" or similar, which will
| *always* compress any non-empty file.)
|
Okay:
def compress(s):
if s=='11': return '11'
elif s=='10': return '1'
elif s=='01': return '0'
elif s=='00': return ''
def uncompress(s):
if s=='11': return '11'
elif s=='1': return '10'
elif s=='0': return '01'
elif s=='': return '00'
Oh, maybe that doesn't count. <0.5wink>
-implicit-lengths-are-fun-ly y'rs, Amit
More information about the Python-list
mailing list