Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. l1= [[a,b,c,x,y,z],[a,b,c,x,y,z],[a,b,c,x,y,z],...]
  2. l2= [z,b,c]
  3.  
  4. while True:
  5. if ...
  6. break
  7.  
  8. l2 = [1,4,20]
  9.  
  10. l1= [[1,2,3,4,5,6],[7,8,9,10,11,12],[13,14,15,16,17,18]]
  11. l2= [18,14,15]
  12. res1 = [ x for x in l1 if l2 == x[5:6]+x[1:3] ]
  13. res2 = [ x for x in l1 if l2 == x[5:6]+x[1:2] ]
  14.  
  15. for item in l1:
  16. здесь выполняем проверку на совпадение
  17.  
  18. #!/usr/bin/env python
  19. from collections import namedtuple
  20.  
  21. Map = namedtuple('Map', 'a,b,c,x,y,z')
  22. l1 = [[a,b,c,x,y,z],[a,b,c,x,y,z],[a,b,c,x,y,z],...]
  23. l2 = [1, 4, 20]
  24.  
  25. z, b = l2[:2] # reference
  26. found_maps = [m for m in map(Map, l1) if z == m.z and b == m.b]
  27.  
  28. found = next((m for m in map(Map, l1) if z == m.z and b == m.b), None)
  29.  
  30. l1 = [[1,4,2,7,3,5],[1,8,9,2,5,3,7],[3,2,1,5]]
  31. res = None
  32. for item in l1:
  33. if 4 in item and 7 in item:
  34. res = item
  35.  
  36. for item in l1:
  37. if (l2[0] in item) and (l2[1] in item):
  38. res = item
  39.  
  40. res = []
  41. for item in l1:
  42. if (l2[0] in item) and (l2[1] in item):
  43. res.append(item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement