Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. c = set('qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM')
  2. s = input()
  3. n = int(input())
  4. ans = True
  5. for i in range(n):
  6.     ss = input()
  7.     if len(s) != len(ss):
  8.         continue
  9.     for j in range(len(s)):
  10.         if s[j] != ss[j]:
  11.             if s[j] == '0' and (ss[j] == 'o' or ss[j] == 'O'):
  12.                 ans = False
  13.             elif s[j] == 'o' and (ss[j] == '0' or ss[j] == 'O'):
  14.                 ans = False
  15.             elif s[j] == 'O' and (ss[j] == '0' or ss[j] == 'o'):
  16.                 ans = False
  17.             elif s[j] == '1' and (ss[j] == 'l' or ss[j] == 'L' or ss[j] == 'i' or ss[j] == 'I'):
  18.                 ans = False
  19.             elif s[j] == 'l' and (ss[j] == '1' or ss[j] == 'L' or ss[j] == 'i' or ss[j] == 'I'):
  20.                 ans = False
  21.             elif s[j] == 'L' and (ss[j] == 'l' or ss[j] == '1' or ss[j] == 'i' or ss[j] == 'I'):
  22.                 ans = False
  23.             elif s[j] == 'i' and (ss[j] == 'l' or ss[j] == 'L' or ss[j] == '1' or ss[j] == 'I'):
  24.                 ans = False
  25.             elif s[j] == 'I' and (ss[j] == 'l' or ss[j] == 'L' or ss[j] == 'i' or ss[j] == '1'):
  26.                 ans = False
  27.             elif s[j] in c and ss[j] in c:
  28.                 if s[j].islower():
  29.                     if s[j] == ss[j].lower():
  30.                         ans = False
  31.                         continue
  32.                 else:
  33.                     if s[j] == ss[j].upper():
  34.                         ans = False
  35.                         continue
  36.                 ans = True
  37.             else:
  38.                 ans = True
  39.                 break
  40.     if not ans:
  41.         break
  42. if ans:
  43.     print('Yes')
  44. else:
  45.     print('No')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement