SHARE
TWEET

Untitled

a guest Oct 21st, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. n=10
  3. r=zip(range(n-1),range(1,n-1))#множество посадочных мест для парочек
  4. seats=sorted(set(r))
  5. print(seats)
  6. ost=set()
  7. while seats!=set():#соседние места к выбранному дожны совпадать по крайним индексам
  8.     place=set(random.sample(seats,1))#выбираем одну пару мест
  9.     print(place)
  10.     temp=set()
  11.     prev=set()
  12.     net=set()
  13.     for i in seats:
  14.         if i in place and temp!=set():#если темпл пустой
  15.             prev.add(temp)
  16.         if temp in place:
  17.             net.add(i)
  18.         l=list(i)
  19.         if ost!=set():
  20.             for j in ost:
  21.                 if j==l[0][0] or j==l[0][1]:###
  22.                     ost.remove(j)#удаляем элемент
  23.         temp=i
  24.     seats=set(seats)
  25.     l=list(prev)
  26.     print(prev)
  27.     print(net)
  28.     if prev!=set() and l[0][1]==list(place)[0][0]:
  29.         ost.add(l[0][0])
  30.         seats-=prev
  31.     l=list(net)
  32.     if net!=set() and l[0][0]==list(place)[0][1]:
  33.         ost.add(l[0][1])
  34.         seats-=net
  35.     seats-=place
  36.     print(sorted(seats))
  37. print(sorted(ost))
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
 
Top