Skip to content

Commit 9d01718

Browse files
committed
Counter
1 parent 02d44c8 commit 9d01718

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

rounds/1_histogram/baseline.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
tokens) in a binary payload.
55
"""
66

7-
from collections import Counter, deque
7+
from collections import Counter
8+
from itertools import pairwise
89

910

1011
def compute_histogram(path: str) -> dict[bytes, int]:
1112
"""Frequency of every 2-byte bigram in the file at ``path``."""
1213
with open(path, "rb") as f:
1314
data = f.read()
14-
return Counter(deque(data, maxlen=2))
15+
16+
return Counter(bytes(bigram) for bigram in pairwise(data))

0 commit comments

Comments
 (0)