September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -31,13 +31,13 @@ def decompress(compressed):
|
|||
|
||||
# Build the dictionary.
|
||||
dict_size = 256
|
||||
dictionary = dict((chr(i), chr(i)) for i in xrange(dict_size))
|
||||
# in Python 3: dictionary = {chr(i): chr(i) for i in range(dict_size)}
|
||||
dictionary = dict((i, chr(i)) for i in xrange(dict_size))
|
||||
# in Python 3: dictionary = {i: chr(i) for i in range(dict_size)}
|
||||
|
||||
# use StringIO, otherwise this becomes O(N^2)
|
||||
# due to string concatenation in a loop
|
||||
result = StringIO()
|
||||
w = compressed.pop(0)
|
||||
w = chr(compressed.pop(0))
|
||||
result.write(w)
|
||||
for k in compressed:
|
||||
if k in dictionary:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue