Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def enc_consume(carrier, nsyms):
- chrs = defaultdict(int)
- i = 0 # see this?
- for i,c in enumerate(carrier):
- # `i` is not used in the loop
- chrs[c] += 1
- if len(chrs) == nsyms:
- break
- return chrs, carrier[i+1:] # but it's used here
- def enc_consume(carrier, nsyms):
- characters = defaultdict(int)
- stream = iter(carrier)
- for char in stream:
- characters[char] += 1
- if len(characters) >= nsyms:
- break
- return characters, ''.join(stream)
- def enc_consume(carrier, nsyms):
- first_unused_idx = 0
- char_cnt = defaultdict(int)
- while first_unused_idx < len(carrier) and len(char_cnt) < nsyms:
- char_cnt[carrier[first_unused_idx]] += 1
- first_unused_idx += 1
- return char_cnt, carrier[first_unused_idx:]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement