Skip to content

Commit

Permalink
Minor change in Sardinas–Patterson algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
rwnobrega committed Jul 28, 2023
1 parent c8fc617 commit 5739350
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/komm/_source_coding/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def is_uniquely_decodable(words: list[Word]) -> bool:
for c1, c2 in it.product(augmented_words, repeat=2):
if c1 != c2 and c1[: len(c2)] == c2:
dangling_suffixes.add(c1[len(c2) :])
if any(suffix in words for suffix in dangling_suffixes):
if dangling_suffixes & set(words):
return False
if all(suffix in augmented_words for suffix in dangling_suffixes):
if dangling_suffixes <= augmented_words:
return True
augmented_words |= dangling_suffixes

Expand Down

0 comments on commit 5739350

Please sign in to comment.