Guest User

Untitled

a guest
Nov 16th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. weight = (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2)
  2. encode = {0:'1',1:'0',2:'X',3:'9',4:'8',5:'7',6:'6',7:'5',8:'4',9:'3',10:'2'}
  3. N = int(input())
  4. count = 0
  5. for i in range(N):
  6. temp = 0
  7. id = input()
  8. try: # find out if the first 17 contain non-numbers
  9. id_nr = list(map(int,list(id[:17])))
  10. except ValueError:
  11. print(id)
  12. continue
  13. check_nr = id[-1]
  14. for i in range(17):
  15. temp += weight[i]*int(id[i])
  16. temp = encode[temp % 11]
  17. if temp == check_nr:
  18. count += 1
  19. continue
  20. else:
  21. print(id)
  22. if count == N:
  23. print('All passed')
Add Comment
Please, Sign In to add comment