Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. p1=[-8,-10,0]
  2. p2=[5,5,10]
  3. p3=[2,-7,3]
  4. p4=[9,-8,-3]
  5.  
  6. v1=[0,0,0]
  7. v2=[0,0,0]
  8. v3=[0,0,0]
  9. v4=[0,0,0]
  10.  
  11. def update(a,b,temp):
  12. if a[0]>b[0]:
  13. temp[0]-=1
  14. elif a[0]<b[0]:
  15. temp[0]+=1
  16.  
  17. if a[1]>b[1]:
  18. temp[1]-=1
  19. elif a[1]<b[1]:
  20. temp[1]+=1
  21.  
  22. if a[2]>b[2]:
  23. temp[2]-=1
  24. elif a[2]<b[2]:
  25. temp[2]+=1
  26.  
  27. return temp
  28.  
  29. stop=False
  30.  
  31. s=0
  32.  
  33. def step():
  34. global v1,v2,v3,v4,p1,p2,p3,p4,history,s,stop
  35. for i in [p1,p2,p3,p4]:
  36. for j in [p1,p2,p3,p4]:
  37. if i!=j:
  38. if i==p1:
  39. v1=update(i,j,v1)
  40. elif i==p2:
  41. v2=update(i,j,v2)
  42. elif i==p3:
  43. v3=update(i,j,v3)
  44. else:
  45. v4=update(i,j,v4)
  46.  
  47. p1=[x + y for x, y in zip(p1, v1)]
  48. p2=[x + y for x, y in zip(p2, v2)]
  49. p3=[x + y for x, y in zip(p3, v3)]
  50. p4=[x + y for x, y in zip(p4, v4)]
  51.  
  52. s+=1
  53.  
  54. if v1==[0,0,0] and v2==[0,0,0] and v3==[0,0,0] and v4==[0,0,0]:
  55. print(s*2)
  56. stop=True
  57.  
  58. while not stop:
  59. step()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement