SHARE
TWEET

Untitled

a guest Nov 19th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #6
  2. text = open('INPUT.TXT').read()
  3. result = 'YES'
  4. letters=['A','B','C','D','E','F','G','H']
  5.  
  6. def check_size():
  7.     if len(text) == 5:
  8.         return True
  9.     else:
  10.         return False
  11.  
  12. def check_defis():
  13.     if str(text[2]) == '-':
  14.         return True
  15.     else:
  16.         return False
  17.  
  18. def check_alphabet (a):
  19.     s = False
  20.     for i in letters:
  21.         if a == i:
  22.             s += True
  23.         else:
  24.             s += False
  25.     if s == True:
  26.         return True
  27.     else:
  28.         return False
  29.        
  30. def check_numbers(n):
  31.     if n >= 1 and n <= 8:
  32.         return True
  33.     else:
  34.         return False
  35.  
  36. def diapazon_numbers(a, b):
  37.     r = abs(a - b)
  38.     if r >= 1 and r <= 2:
  39.         return True
  40.     else:
  41.         return False
  42.    
  43. def numbers_1(a, b):
  44.     if abs(a - b) == 1:
  45.         return True
  46.     else:
  47.         return False
  48.  
  49. size = check_size()
  50. defis = check_defis()
  51. if size == True:
  52.     letter1 = check_alphabet(text[0])
  53.     letter2 = check_alphabet(text[3])
  54.     n1 = check_numbers(int(text[1]))
  55.     n2 = check_numbers(int(text[4]))
  56. else:
  57.     result = 'ERROR'
  58.  
  59. if letter1 == letter2 == defis == size == n1 == n2 == True:
  60.     check = True
  61. else:
  62.     check = False
  63. if check == True:
  64.     dl = diapazon_numbers(int(letters.index(text[0])), int(letters.index(text[3])))
  65.     dn = diapazon_numbers(int(text[1]), int(text[4]))
  66.     if dl == dn == True:
  67.         dl1 = numbers_1(int(letters.index(text[0])), int(letters.index(text[3])))
  68.         dn1 = numbers_1(int(text[1]), int(text[4]))
  69.         if dn1 != dl1:
  70.             result = 'YES'
  71.         else:
  72.             result = 'NO'
  73.     else:
  74.         result = 'NO'
  75. else:
  76.     result = 'ERROR'
  77.    
  78. file = open('OUTPUT.TXT', 'w')
  79. file.write(str(result))
  80. file.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top