Advertisement
Guest User

Untitled

a guest
Oct 21st, 2023
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. lista = [[2, 6], [1, 3, 4], [2], [2], [7], [1], [6]]
  2. lista_bool = [False for x in lista]
  3. kolejka = []
  4. for element in lista[0]:
  5. kolejka.append(element)
  6. lista_bool[0] = True
  7. while len(kolejka) > 0:
  8. value = kolejka.pop(0)
  9. if not lista_bool[value - 1]:
  10. lista_bool[value-1] = True
  11. for index in lista[value-1]:
  12. kolejka.append(index)
  13. print(lista_bool)
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement