We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e21663f commit 5825cf3Copy full SHA for 5825cf3
1 file changed
rounds/1_histogram/solution.py
@@ -6,9 +6,13 @@
6
"""
7
8
9
+from collections import Counter
10
+
11
12
def compute_histogram(path: str) -> dict[bytes, int]:
13
"""Frequency of every 2-byte bigram in the file at ``path``."""
- # TODO: remove this delegation and write your own implementation here.
- from .baseline import compute_histogram as _baseline
14
+ with open(path, "rb") as f:
15
+ data = f.read()
16
- return _baseline(path)
17
+ counts = Counter(data[i : i + 2] for i in range(len(data) - 1))
18
+ return counts
0 commit comments