Skip to content

Commit 5825cf3

Browse files
committed
r1: use coutner
1 parent e21663f commit 5825cf3

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

rounds/1_histogram/solution.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
"""
77

88

9+
from collections import Counter
10+
11+
912
def compute_histogram(path: str) -> dict[bytes, int]:
1013
"""Frequency of every 2-byte bigram in the file at ``path``."""
11-
# TODO: remove this delegation and write your own implementation here.
12-
from .baseline import compute_histogram as _baseline
14+
with open(path, "rb") as f:
15+
data = f.read()
1316

14-
return _baseline(path)
17+
counts = Counter(data[i : i + 2] for i in range(len(data) - 1))
18+
return counts

0 commit comments

Comments
 (0)