Skip to content

Instantly share code, notes, and snippets.

@eaydin
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save eaydin/d9a7cfc7b15033787e8d to your computer and use it in GitHub Desktop.

Select an option

Save eaydin/d9a7cfc7b15033787e8d to your computer and use it in GitHub Desktop.
def parity_check(incoming, type="even"):
"""Pass the incoming bits as string"""
if type != "even" and type != "odd":
return -1
if type == "even":
sum = 0
if type == "odd":
sum = 1
for i in incoming: sum += int(i)
return sum % 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment