Created
October 9, 2021 16:42
-
-
Save Dante383/ccac52236e665ecbd005bab72c270982 to your computer and use it in GitHub Desktop.
calculate księga wieczysta checksum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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