Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- weight = (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2)
- encode = {0:'1',1:'0',2:'X',3:'9',4:'8',5:'7',6:'6',7:'5',8:'4',9:'3',10:'2'}
- N = int(input())
- count = 0
- for i in range(N):
- temp = 0
- id = input()
- try: # find out if the first 17 contain non-numbers
- id_nr = list(map(int,list(id[:17])))
- except ValueError:
- print(id)
- continue
- check_nr = id[-1]
- for i in range(17):
- temp += weight[i]*int(id[i])
- temp = encode[temp % 11]
- if temp == check_nr:
- count += 1
- continue
- else:
- print(id)
- if count == N:
- print('All passed')
Add Comment
Please, Sign In to add comment