We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 02d44c8 commit 9d01718Copy full SHA for 9d01718
1 file changed
rounds/1_histogram/baseline.py
@@ -4,11 +4,13 @@
4
tokens) in a binary payload.
5
"""
6
7
-from collections import Counter, deque
+from collections import Counter
8
+from itertools import pairwise
9
10
11
def compute_histogram(path: str) -> dict[bytes, int]:
12
"""Frequency of every 2-byte bigram in the file at ``path``."""
13
with open(path, "rb") as f:
14
data = f.read()
- return Counter(deque(data, maxlen=2))
15
+
16
+ return Counter(bytes(bigram) for bigram in pairwise(data))
0 commit comments