Anders and Briegel in Python
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 8 gadiem
1234567891011121314151617181920212223242526272829303132
  1. from abp import GraphState
  2. from anders_briegel import graphsim
  3. from abp import clifford
  4. import random, difflib, re
  5. from copy import deepcopy
  6. def isequal(a, b):
  7. """ TODO: Sketchy as you like. Remove this abomination """
  8. aa = a.get_adj_list()
  9. bb = b.adj_list()
  10. return re.sub("\\s", "", aa) == re.sub("\\s", "", bb)
  11. clifford.use_old_cz()
  12. N = 3
  13. a = graphsim.GraphRegister(N)
  14. b = GraphState(range(N))
  15. previous_state, previous_cz = None, None
  16. while isequal(a, b):
  17. if random.random()>0.5:
  18. j = random.randint(0, N-1)
  19. a.hadamard(j)
  20. b.act_hadamard(j)
  21. else:
  22. q = random.randint(0, N-2)
  23. if a!=b:
  24. a.cphase(q, q+1)
  25. b.act_cz(q, q+1)