diff --git a/README.md b/README.md index 44e0723..27b7c82 100644 --- a/README.md +++ b/README.md @@ -91,3 +91,4 @@ scripts/ ``` Each round's `data/` directory is generated locally and gitignored. +This is sshbur's PR diff --git a/rounds/1_histogram/solution.py b/rounds/1_histogram/solution.py index dffbee5..836dcf2 100644 --- a/rounds/1_histogram/solution.py +++ b/rounds/1_histogram/solution.py @@ -6,9 +6,13 @@ """ +from collections import Counter + + def compute_histogram(path: str) -> dict[bytes, int]: """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 + with open(path, "rb") as f: + data = f.read() - return _baseline(path) + counts = Counter(data[i : i + 2] for i in range(len(data) - 1)) + return counts