Skip to content

Instantly share code, notes, and snippets.

@ph87
Last active August 29, 2015 14:02
Show Gist options
  • Save ph87/d9e44129b701e5a0f230 to your computer and use it in GitHub Desktop.
Save ph87/d9e44129b701e5a0f230 to your computer and use it in GitHub Desktop.
Sum Check Schema for IOS 7064 Mod 11-2 (Unique Identifier for People, People's Republic of China)
code = '12346830281720938x' # check sum equal 10, maped to 'x'
sum = 0
for i in code[:-1]:
sum = ( sum + int(i, 10)) * 2
sum_mod = sum % 11
sum_check = (12 - sum_mod ) % 11
sum_check = 'x' if sum_check == 10 else str(sum_check)
assert sum_check == code[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment