• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
5%
SHARE
TWEET

# Untitled

a guest Feb 27th, 2013 29 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from __future__ import division
2. import itertools as it
3. import numpy as np
4. l = input('How many lattices?_')
5. m = input('How many markers?_')
6. sums = 0
7. sumcount = 0
8. pos = 1
9. neg = -1
10. L = it.product([-1,1], repeat =l)
11. M = range(0,l)
12. markers = it.combinations(M, m)
13. k = 0
14. for ring in L:
15.     for marker in markers:
16.         while k < 2*len(ring):
17.             ring = list(np.roll(ring,1))
18.             for x in marker:
19.                 t = ring.pop(x)
20.                 if t < 0:
21.                     ring.insert(x,pos)
22.                 elif t > 0:
23.                     ring.insert(x,neg)
24.                 else:
25.                     print('This is why we cant have nice things...')
26.                 sums = sums + abs(sum(ring))
27.                 sumcount = sumcount + 1
28.                 k = k + 1
29.         k = 0
30.     k = 0
31.
32. print 'Average deviation: ', sums/sumcount
RAW Paste Data
Top