Skip to content

Instantly share code, notes, and snippets.

@Dante383
Created October 9, 2021 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dante383/ccac52236e665ecbd005bab72c270982 to your computer and use it in GitHub Desktop.
Save Dante383/ccac52236e665ecbd005bab72c270982 to your computer and use it in GitHub Desktop.
calculate księga wieczysta checksum
chars_translate = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'X': 10 ,'A': 11, 'B': 12, 'C': 13, 'D': 14, 'E': 15, 'F': 16, 'G': 17, 'H': 18, 'I': 19, 'J': 20, 'K': 21, 'L': 22, 'M': 23, 'N': 24, 'O': 25, 'P': 26, 'R': 27, 'S': 28, 'T': 29, 'U': 30, 'W': 31, 'Y': 32, 'Z': 33}
weights = [1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7]
def calculate_checksum (number):
numbers_sum = 0
for idx, val in enumerate(weights):
numbers_sum += chars_translate[number[idx]]*val
return numbers_sum % 10
print(calculate_checksum("WL1A00272852"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment