Skip to content

Commit

Permalink
Merge pull request #10 from mmlouamri/fix-vn
Browse files Browse the repository at this point in the history
Fixing the Von Neumann Extractor
  • Loading branch information
y-richie-y authored Aug 20, 2024
2 parents 1a4ccc1 + 450764b commit 9dabe5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cryptomite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,4 @@ def closest_na_set(k: int) -> int:

def von_neumann(bits: BitsT) -> BitsT:
""" Extract using Von-Neumann extractor. """
return [x for x, y in zip(bits[::2], bits[1::2]) if x == y]
return [x for x, y in zip(bits[::2], bits[1::2]) if x != y]
9 changes: 5 additions & 4 deletions test/test_vn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

vn_testcases = [
([], []),
([0, 1, 0, 1], []),
([0, 0, 0, 0], [0, 0]),
([0, 0, 1, 1], [0, 1]),
([0, 1, 0, 1], [0, 0]),
([0, 0, 0, 0], []),
([0, 0, 1, 1], []),
([0, 0, 0, 1, 1, 0, 1, 1, 1], [0, 1]),
([1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0],
[0, 1, 1, 0, 1])
[1, 1, 1, 0, 1])
]


Expand Down

0 comments on commit 9dabe5d

Please sign in to comment.