nq1s788

9 есть ли в строке подходящие пары

Jan 26th, 2026
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. a = [[1, 2, 3, 4, 5], [7, 8, 9, 10, 11]]
  2. cnt = 0
  3. for e in a:
  4.     f = False
  5.     for i in range(5):
  6.         b = e.copy()
  7.         b.pop(i)
  8.         if (b[0] + b[1]) / 2 == (b[2] + b[3]) / 2 == e[i]:
  9.             f = True
  10.         if (b[0] + b[2]) / 2 == (b[1] + b[3]) / 2 == e[i]:
  11.             f = True
  12.         if (b[0] + b[3]) / 2 == (b[1] + b[2]) / 2 == e[i]:
  13.             f = True
  14.     if f:
  15.         cnt += 1
  16. print(cnt)
Advertisement
Add Comment
Please, Sign In to add comment