We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d99cc18 commit 6d156e0Copy full SHA for 6d156e0
1 file changed
rounds/1_histogram/solution.py
@@ -11,10 +11,12 @@ def compute_histogram(path: str) -> dict[bytes, int]:
11
with open(path, "rb") as f:
12
data = f.read()
13
counts: dict[bytes, int] = {}
14
+ bigrams_seen = set()
15
for i in range(len(data) - 1):
16
bigram = data[i : i + 2]
- if bigram in counts:
17
+ if bigram in bigrams_seen:
18
counts[bigram] += 1
19
else:
20
+ bigrams_seen.add(bigram)
21
counts[bigram] = 1
22
return counts
0 commit comments