Advertisement
Korotkodul

dem13.n9

Jun 13th, 2023
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. f = open('N9.txt')
  2. lines = f.readlines()
  3. f.close()
  4. #print(lines[0], lines[1], lines[2])
  5.  
  6. def f(a):
  7.     for i in a:
  8.         if i < 1 or i > 8:
  9.             return 0
  10.     x1 = a[0]
  11.     y1 = a[1]
  12.     x2 = a[2]
  13.     y2 = a[3]
  14.     dx = abs(x1 - x2)
  15.     dy = abs(y1 - y2)
  16.     A = min(dx,dy)
  17.     B = max(dx,dy)
  18.     return A == 1 and B == 2
  19.  
  20.  
  21. k = 0
  22.  
  23.  
  24. for line in lines:
  25.     a = [int(i) for i in line.split()]
  26.     if f(a):
  27.         k += 1
  28.         print(a)
  29.  
  30. print(k)
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement