diff --git a/README.md b/README.md index 44e0723..11a7d43 100644 --- a/README.md +++ b/README.md @@ -91,3 +91,4 @@ scripts/ ``` Each round's `data/` directory is generated locally and gitignored. +This is Stefanie's PR diff --git a/rounds/1_histogram/solution.py b/rounds/1_histogram/solution.py index dffbee5..987c315 100644 --- a/rounds/1_histogram/solution.py +++ b/rounds/1_histogram/solution.py @@ -5,10 +5,11 @@ own faster implementation. """ +from collections import Counter +from itertools import pairwise +from pathlib import Path + 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 - - return _baseline(path) + return Counter(bytes(bigram) for bigram in pairwise(Path(path).read_bytes()))